/*!
 * jquery.base64.js 0.1 - https://github.com/yckart/jquery.base64.js
 * Makes Base64 en & -decoding simpler as it is.
 *
 * Based upon: https://gist.github.com/Yaffle/1284012
 *
 * Copyright (c) 2012 Yannick Albert (http://yckart.com)
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php).
 * 2013/02/10
 **/
;(function($) {
 
  var b64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",
      a256 = '',
      r64 = [256],
      r256 = [256],
      i = 0;

  var UTF8 = {

      /**
       * Encode multi-byte Unicode string into utf-8 multiple single-byte characters
       * (BMP / basic multilingual plane only)
       *
       * Chars in range U+0080 - U+07FF are encoded in 2 chars, U+0800 - U+FFFF in 3 chars
       *
       * @param {String} strUni Unicode string to be encoded as UTF-8
       * @returns {String} encoded string
       */
      encode: function(strUni) {
          // use regular expressions & String.replace callback function for better efficiency
          // than procedural approaches
          var strUtf = strUni.replace(/[\u0080-\u07ff]/g, // U+0080 - U+07FF => 2 bytes 110yyyyy, 10zzzzzz
              function(c) {
                  var cc = c.charCodeAt(0);
                  return String.fromCharCode(0xc0 | cc >> 6, 0x80 | cc & 0x3f);
              })
              .replace(/[\u0800-\uffff]/g, // U+0800 - U+FFFF => 3 bytes 1110xxxx, 10yyyyyy, 10zzzzzz
                  function(c) {
                      var cc = c.charCodeAt(0);
                      return String.fromCharCode(0xe0 | cc >> 12, 0x80 | cc >> 6 & 0x3F, 0x80 | cc & 0x3f);
                  });
          return strUtf;
      },

      /**
       * Decode utf-8 encoded string back into multi-byte Unicode characters
       *
       * @param {String} strUtf UTF-8 string to be decoded back to Unicode
       * @returns {String} decoded string
       */
      decode: function(strUtf) {
          // note: decode 3-byte chars first as decoded 2-byte strings could appear to be 3-byte char!
          var strUni = strUtf.replace(/[\u00e0-\u00ef][\u0080-\u00bf][\u0080-\u00bf]/g, // 3-byte chars
              function(c) { // (note parentheses for precence)
                  var cc = ((c.charCodeAt(0) & 0x0f) << 12) | ((c.charCodeAt(1) & 0x3f) << 6) | (c.charCodeAt(2) & 0x3f);
                  return String.fromCharCode(cc);
              })
              .replace(/[\u00c0-\u00df][\u0080-\u00bf]/g, // 2-byte chars
                  function(c) { // (note parentheses for precence)
                      var cc = (c.charCodeAt(0) & 0x1f) << 6 | c.charCodeAt(1) & 0x3f;
                      return String.fromCharCode(cc);
                  });
          return strUni;
      }
  };

  while(i < 256) {
      var c = String.fromCharCode(i);
      a256 += c;
      r256[i] = i;
      r64[i] = b64.indexOf(c);
      ++i;
  }

  function code(s, discard, alpha, beta, w1, w2) {
      s = String(s);
      var buffer = 0,
          i = 0,
          length = s.length,
          result = '',
          bitsInBuffer = 0;

      while(i < length) {
          var c = s.charCodeAt(i);
          c = c < 256 ? alpha[c] : -1;

          buffer = (buffer << w1) + c;
          bitsInBuffer += w1;

          while(bitsInBuffer >= w2) {
              bitsInBuffer -= w2;
              var tmp = buffer >> bitsInBuffer;
              result += beta.charAt(tmp);
              buffer ^= tmp << bitsInBuffer;
          }
          ++i;
      }
      if(!discard && bitsInBuffer > 0) result += beta.charAt(buffer << (w2 - bitsInBuffer));
      return result;
  }

  var Plugin = $.base64 = function(dir, input, encode) {
      return input ? Plugin[dir](input, encode) : dir ? null : this;
  };

  Plugin.btoa = Plugin.encode = function(plain, utf8encode) {
      plain = Plugin.raw === false || Plugin.utf8encode || utf8encode ? UTF8.encode(plain) : plain;
      plain = code(plain, false, r256, b64, 8, 6);
      return plain + '===='.slice((plain.length % 4) || 4);
  };

  Plugin.atob = Plugin.decode = function(coded, utf8decode) {
      coded = String(coded).split('=');
      var i = coded.length;
      do {--i;
          coded[i] = code(coded[i], true, r64, a256, 6, 8);
      } while (i > 0);
      coded = coded.join('');
      return Plugin.raw === false || Plugin.utf8decode || utf8decode ? UTF8.decode(coded) : coded;
  };
}(jQuery));
/*
 * @Descripttion: 
 * @Author: whyjs
 * @Date: 2022-06-09 10:16:29
 * @LastEditors: whyjs
 * @LastEditTime: 2023-03-15 17:43:07
 */
//修改渠道信息
$(function(){
    var hostname = window.location.hostname;//获取域名
    var channelStorge = layui.data(hostname);//获取本地渠道信息
    $.isEmptyObject(channelStorge)?getChannel():setChannelDom(channelStorge.channel,true)//判断本地是否有渠道信息
    function getChannel(){//获取渠道信息
        ajaxChannel(hostname)
            .done(function (data) {
                layui.data(hostname, {
                    key: 'channel'
                    ,value: data
                });
                setChannelDom(data)
            })
            .fail(function () {
                fnBase._toast('获取渠道信息失败，请联系管理员！')
            })
    }
    function setChannelDom(data,isResert){//设置渠道信息
         if(!data){
            if(isResert) getChannel()
            return
         }
        $('[channel]').each(function(){
            var attr = $(this).attr('channel')
            if(attr==='html'){
                $(this).html(data[$(this).data()['channelkey']])
            }else{
                $(this).attr(attr,data[$(this).data()['channelkey']]);
            }
        })
        if(isResert) getChannel()
        // 处理浏览器图标和title
        try {
            document.getElementById('faviconIco').href = data.browserIconFileLink
            document.title=document.title.replace(/航信/, data.accountsReceivable)
        } catch (error) {
            
        }
       
    }
    function ajaxChannel(){//渠道信息请求
        var dtd= $.Deferred()
        fnBase.ajaxJson({
            type: "GET",
            url: '/goldnet-enterprise-client/configcenter/channelDetail',
            data:{
                domainName:fnBase._getLocalaionOrigin()
            },
            success: function (response) { 
              if(response.code === 200&&response.data){
                dtd.resolve($.extend({},response.data))
                setCookie('tenantId',response.data.tenantId)
              }else{
                dtd.reject() 
              }
              
            },
            error: function (XMLHttpRequest, textStatus, errorThrown) {
                dtd.reject() 
              },
          });
        
        return dtd.promise()

    }
});
var channelFindObj = function (type) {
var hostname = window.location.hostname;//获取域名
try {
    return layui.data(hostname).channel[type];
} catch (error) {
    return ''
}
};
// <img channel="src" data-channelkey="platformLogoFileLink">
// 修改渠道信息 html标签必须包含 channel属性 data-channelkey属性
// channel 要修改的dom属性
// data-channelkey 对应ajax的值
/*公用的页面初始化基础方法*/
var fnBase = {
  token: '',
  IEVersion: IEVersion,
  permission: {}, //按钮级权限
  regisAuthBankProc: null,
  ENV: 'default',
  loginOut: '',
  baseUrl: 'http://127.0.0.1',
  baseWebUrl: '',
  init: function () {
    regisAuthBankProc = this
    jQuery.support.cors = true
    window.tradeTableObject = {
      isInclude: false,
    }
    this.token = getCookie('GoldNet-Auth') || ''
    // this._initJqueryCommon()
  },
  setLoginCookie: function (data) {
    // 登陆的对象
    // { 
    //   'GoldNet-Auth':'',
    //   'accountStatus':'',
    //   'userInfo':'',
    //   'workGroupInfo':''
    // }
    var d = data || {}
    _.forOwn(d, function (value, key) {
      setCookie(key, value);
    });

  },
  // 退出登录
  logout: function () {
    fnBase.ajaxJson({
      type: "GET",
      url: "/goldnet-enterprise-client/api/v1/portal/portalinfo",
      success: function (res) {
        var url = '/avic/login'
        try {
          if (res.data.portalDomain) {
            url = 'https://' + res.data.portalDomain
          }
        } catch (error) {

        }
        window.location.href = url
        clearAllCookie();
      },
      error: function (params) {
        window.location.href = '/avic/login'
        clearAllCookie();
      }
    });
  },
  valFiltersObj: function (obj) {
    var o = obj || {}
    if (IEVersion()) {

      var e = {}
      _.forEach(o, function (value, key) {
        if (value) {
          e[key] = value
        }
      });

      return e
    } else {
      return o
    }

  },
  autoHeaderWidth: function (t) {
    var viewElem = t.elem.next('.layui-table-view'),
      headerWidth = viewElem.find('.layui-table-header > table').width();
    viewElem.find('.layui-table-main > table').css({ 'display': ' inline-block' }).width(headerWidth);
  },
  _initLayUiTips: function (type) {
    $('*[lay-tips]').unbind('mouseenter').on('mouseenter', function () {
      var content = $(this).attr('lay-tips');
      var color = $(this).attr('lay-tips-color') || '#3A3D49'
      var textcolor = $(this).attr('lay-tips-text-color') || '#fff'
      console.log(textcolor)
      this.index = layer.tips('<div style="color:' + textcolor + ';">' + content + '</div>', this, {
        time: -1
        , maxWidth: 280
        , tips: [type ? type : 3, color]
      });
    }).unbind('mouseleave').on('mouseleave', function () {
      layer.close(this.index);
    }).on('click', function () {
      layer.close(this.index);
    });
  },
  _toast: function (text, option) {
    var o = option || {}
    var d = ''
    if (o.type == 'success') {
      d = '<div>' + text + '</div>'
    } else {
      d = '<div>' + text + '</div>'
    }
    layer.open({
      content: d,
      time: o.time || 3000,
      shade: !1,
      skin: o.type == 'success' ? 'layui-layer-hui-success' : 'layui-layer-hui-error',
      title: !1,
      closeBtn: !1,
      btn: !1,
      resize: !1,
      // end: a
    })
    // debugger
  },
  /**
  * @name: 初始化jquery防抖
  * @test: test font
  * @msg:
  * @param {*}
  * @return {*}
  */
  _initJqueryCommon: function () {
    // 改造 jquery 事件绑定，处理 click 事件全局防抖
    jQuery.fn.extend({
      on: function (a, b, c, d, e) {
        var f, g, m = jQuery;
        if ("object" == typeof a) {
          "string" != typeof b && (c = c || b,
            b = void 0);
          for (f in a)
            this.on(f, b, c, a[f], e);
          return this
        }
        if (null == c && null == d ? (d = b,
          c = b = void 0) : null == d && ("string" == typeof b ? (d = c,
            c = void 0) : (d = c,
              c = b,
              b = void 0)),
          d === !1)
          d = bb;
        else if (!d)
          return this;
        return 1 === e && (g = d,
          d = function (a) {
            return m().off(a),
              g.apply(this, arguments)
          }
          ,
          d.guid = g.guid || (g.guid = m.guid++)),
          this.each(function () {
            if (m.inArray(this.nodeName, ['BUTTON', '#document']) > -1) {
              m.event.add(this, a, _.debounce(d, 300), c, b)
            } else {
              m.event.add(this, a, d, c, b)
            }
          })
      }

      // on: function (a, b, c, d, e) {
      //   var f, g;
      //   if ("object" == typeof a) {
      //     "string" != typeof b && ((c = c || b), (b = void 0));
      //     for (f in a) this.on(f, b, c, a[f], e);
      //     return this;
      //   }
      //   if (
      //     (null == c && null == d
      //       ? ((d = b), (c = b = void 0))
      //       : null == d &&
      //         ("string" == typeof b
      //           ? ((d = c), (c = void 0))
      //           : ((d = c), (c = b), (b = void 0))),
      //     d === !1)
      //   )
      //     d = bb;
      //   else if (!d) return this;
      //   return (
      //     1 === e &&
      //       ((g = d),
      //       (d = function (a) {
      //         return m().off(a), g.apply(this, arguments);
      //       }),
      //       (d.guid = g.guid || (g.guid = m.guid++))),
      //     this.each(function () {
      //       m.event.add(this, a, d, c, b);
      //     })
      //   );
      // }
    })
  },

  _getLocalaionOrigin: function () {
    var location = ''
    if (!window.location.origin) {
      location = window.location.protocol + "//" + window.location.hostname + (window.location.port ? ':' + window.location.port : '');
    } else {
      location = window.location.origin;
    }
    if(fnBase.ENV=='local'){
      // return 'https://web-test.hang-xin.cn'
      // // return 'http://192.168.1.212:8080'
      // return 'https://web-test.hang-xin.cn'
      // // return 'http://192.168.1.212:8080'
      return 'https://web-uat.hang-xin.cn'
      // return 'http://172.30.255.21:31439'
    }
    
    return location
  },

  /**
   * @name: 权限相关
   * @test: test font
   * @msg:
   * @param {*}
   * @return {*}
   */
  _initButtons: function (fun, async) {
    var result = []
    function getCode(list) {
      $.each(list, function (index, ele) {
        if (typeof ele === 'object') {
          var chiildren = ele.children
          var code = ele.code
          var category = ele.category
          if (chiildren && chiildren.length > 0) {
            getCode(chiildren)
          } else {
            if (category === 2) {
              result.push(code)
            }
          }
        }
      })
    }
    fnBase.ajaxJson({
      type: 'POST',
      url: '/goldnet-enterprise-client/menu/buttons',
      async: async,
      // data: {
      //   sysCode: 'hx_qy',
      // },
      success: function (response) {
        if (response.code === 200) {
          var permission = {}
          getCode(response.data)
          $.each(result, function (index, ele) {
            permission[ele] = true
          })
          fnBase.permission = permission
          fun()
        } else {
          fnBase._toast('获取权限失败！')
        }
      },
    })
  },
  // 获取按钮级权限
  getPermission: function (type) {
    try {
      if (
        fnBase.permission[type] == 'null' ||
        fnBase.permission[type] == null ||
        fnBase.permission[type] == 'undefined' ||
        fnBase.permission[type] == undefined ||
        fnBase.permission[type] == ''
      ) {
        return false
      } else {
        return fnBase.permission[type]
      }
    } catch (error) {
      return false
    }
  },
  // 设置按钮级权限
  setPermission: function () {
    $.each(fnBase.permission, function (key, item) {
      if (fnBase.permission[key]) {
        // $("[v-permission=" + key + "]").css({ "display": "inline-block" })
        $("[v-permission=" + key + "]").show()
      }
    })
  },


  /**
   * @name: ajax请求相关
   * @test: test font
   * @msg:
   * @param {*}
   * @return {*}
   */
  //自定义header
  headerAvicFn: function () {
    return {
      Authorization: 'Basic aHg6aHhfc2VjcmV0',
      'GoldNet-Auth': getCookie('GoldNet-Auth') || '',
      "tenantId": getCookie('tenantId') || '',
      "Tenant-Id": getCookie('tenantId') || '',
      "Client-Code": "qy",
      //'sysCode': getCookie('sysCode') || '',
      "If-Modified-Since": "0",
      "Cache-Control": "no-cache"
    }
  },
  // 初始化ajax请求头
  _initBaseUrl: function (url) {
    if (IEVersion()) {
      fnBase.baseUrl = '/hx-egg'
    } else {
      fnBase.baseUrl = url
    }
  },
  // 获取请求头
  baseUrlFun: function () {
    if (IEVersion()) {
      return '/hx-egg'
    } else {
      return fnBase.baseUrl
    }
  },
  ajaxJson: function (option) {

    if (this.token && this.token.length > 0 && this.token !== getCookie('GoldNet-Auth')) {
      window.location.href = "/avic/login"
      return
    }
    var fullUrl = (option.baseUrl || fnBase.baseUrl) + option.url
    var data = option.data || {}
    var type = option.type || 'POST'
    if (type.toUpperCase() === 'POST') {
      data = JSON.stringify(option.data || {})
    }
    var layerIsErr = option.layerIsErr || false
    return $.ajax({
      url: fullUrl || '', //设置后覆盖表单action
      timeout: option.timeout || 20000, //超时时间设置，单位毫秒
      dataType: option.dataType || 'json',
      type: option.type || 'POST',
      contentType: 'application/json;charset=UTF-8',
      headers: $.extend({}, fnBase.headerAvicFn(), option.headers || {}),
      data: data,
      async: typeof option.async == 'boolean' ? option.async : true,
      beforeSend: function () {
        //提交之前处理
        option.beforeSend && option.beforeSend()
      },
      success: function (response) {
        //获取状态码
        var status = response.code
        var message = response.msg || response.error_description || '未知错误'
        //如果是401则跳转到登录页面
        if (status === 401) {
          window.location.href = '/avic/login'
        }
        if (
          option.url == '/goldnet-enterprise-client/sysUser/find-by-account'
        ) {
          //提交成功处理
          option.success && option.success(response)
          return
        }
        // 如果请求为非200否者默认统一处理
        if (status !== 200) {
          layerIsErr ? fnBase._toast(message) : layer.msg(message)
          option.error && option.error(response)
          return
        }
        //提交成功处理
        option.success && option.success(response)
      },
      error: function (XMLHttpRequest, textStatus, errorThrown) {
        if (XMLHttpRequest.status === 401) {
          clearAllCookie()
          window.location.href = '/avic/login'
        } else {
          var message = ''
          try {
            message = XMLHttpRequest.responseJSON
            ? XMLHttpRequest.responseJSON.msg
            : JSON.parse(XMLHttpRequest.responseText).msg 
          } catch (error) {
            
          }
          
          layerIsErr ? fnBase._toast(message) : layer.msg(message)
        }
        //提交失败处理
        option.error && option.error(XMLHttpRequest, textStatus, errorThrown)
      },
      complete: function (XMLHttpRequest, status) {
        option.complete && option.complete(XMLHttpRequest)
        if (status == 'timeout') {
          layer.msg('请求超时！')
        }else if (XMLHttpRequest.status === 0) {
          layer.msg('您当前的网络环境不通，请检查后，刷新页面重试！')
        }
      },
    })
  },
  ajaxForm: function (option) {
    if (this.token && this.token.length > 0 && this.token !== getCookie('GoldNet-Auth')) {
      window.location.href = "/avic/login"
      return
    }
    var fullUrl = fnBase.baseUrl + option.url
    var layerIsErr = option.layerIsErr || false
    $.ajax({
      url: fullUrl || '', //设置后覆盖表单action
      dataType: option.dataType || 'json',
      timeout: option.timeout || 10000, //超时时间设置，单位毫秒
      type: option.type || 'POST',
      headers: $.extend({}, fnBase.headerAvicFn(), option.headers || {}),
      data: option.data || {},
      async: typeof option.async == 'boolean' ? option.async : true,
      beforeSend: function () {
        //提交之前处理
        option.beforeSend && option.beforeSend()
      },
      success: function (response) {
        //获取状态码
        var status = response.code
        var message = response.msg || response.error_description || '未知错误'
        //如果是401则跳转到登录页面
        if (status === 401) {
          document.c
          window.location.href = '/avic/login'
        }

        // 如果请求为非200否者默认统一处理
        if (status !== 200) {
          layerIsErr ? fnBase._toast(message) : layer.msg(message)
          option.error && option.error(response)
          return
        }
        //提交成功处理
        option.success && option.success(response)
      },
      error: function (XMLHttpRequest, textStatus, errorThrown) {
        if (XMLHttpRequest.status === 401) {
          clearAllCookie()
          window.location.href = '/avic/login'
        } else {
          //console.log(XMLHttpRequest.responseJSON.msg);
          var message = XMLHttpRequest.responseJSON ? XMLHttpRequest.responseJSON.msg : ''
          layerIsErr ? fnBase._toast(message) : layer.msg(message)
        }
        //提交失败处理
        option.error && option.error(XMLHttpRequest, textStatus, errorThrown)
      },
      complete: function (XMLHttpRequest, status) {
        option.complete && option.complete(XMLHttpRequest)
        if (status == 'timeout') {
          layer.msg('请求超时！')
        }
      },
    })
  },
  ajaxCommon: function (option) {
    $.ajax($.extend(option,{
      url:fnBase.baseUrl + option.url,
      headers: $.extend({}, fnBase.headerAvicFn(), option.headers || {}),
    }))
  },


  /**
   * @name: 文件下载预览相关
   * @test: test font
   * @msg:
   * @param {*}
   * @return {*}
   */

  download: function (data, strFileName, strMimeType) {
    if (IEVersion()) {
      window.open(data)
    } else {
      download(encodeURI(data))
    }

  },
  _commonGetFileLink:function (id) {
    var dtd = $.Deferred();
    fnBase.ajaxJson({
      type: "get",
      url: '/goldnet-enterprise-client/comm/file/down',
      timeout:20000,
      data: { fileId: id }, 
      success: function (response) {
        if(response.data.fileId){
          dtd.resolve(response.data)
        }else{
          dtd.reject()
        }
        
      },
      error:function () {
        dtd.reject()
     }
      
    });
    return dtd.promise(); 
  },
  _commonPreview: function (id) {
    fnBase.ajaxJson({
      type: "get",
      url: '/goldnet-enterprise-client/comm/file/down',
      data: { fileId: id },
      success: function (response) {
        var url = response.data.fileLink
        if (!IsPicture(url)) {
          fnBase.download(url)
        } else {
          if (!document.getElementById('_hxCommonImgPreview')) {
            $('body').append('<div id="_hxCommonImgPreview" style="display:none;"></div>')
          }
          $('#_hxCommonImgPreview').viewer("init", { url: 'data-original', zIndex: 1000000001, alwaysBuild: true, fromJson: url, dataSeparator: '|' });
        }

      }
    });
  },
  // 公共文件预览，下载 
  _commonOpenPreview: function (opt) {
    var option = $.extend({},{
      title:'查看'
    },opt||{})
    if(!option.fileId){
      layer.msg('文件id 不能为空！')
      return
    }
    layer.open({
      type: 1,
      title: option.title,
      offset: 't',
      area: ['80%', '90%'],
      maxmin:true,
      skin: 'footBtn-box',
      btn: ['下载', '取消'],
      content: '<iframe class="medicalRecordHTML" frameborder="0" style="width:100%;height:99%;" ></iframe>',
      success: function (layero) {
        fnBase.ajaxCommon({
          type: "get",
          url: "/goldnet-file-preview-service/onlinePreview",
          data: {fileId: option.fileId},
          success:function (fileHtml) {
            var iframe = layero.find(".medicalRecordHTML")[0]
            // document.getElementById('medicalRecordHTML').src = JSON.stringify(fileHtml);
            if (!!window.ActiveXObject || "ActiveXObject" in window) {//判断是否是IE浏览器
              //对于IE,可以使用这种方式.同时,IE的iframe不支持srcdoc属性,这是唯一的方式.
                // document.getElementById("someDiv").appendChild(iframe);
                iframe.contentWindow.document.open();
                iframe.contentWindow.document.write(fileHtml);
                iframe.contentWindow.document.close();
            }
            else {
                //对于其他浏览器,直接设置srcdoc属性就可以了.而且,如果想设置iframe.contentWindow.document也是不可能拿的,因为iframe.contentWindow根据安全策略无法访问,
                iframe.srcdoc = fileHtml;
                // document.getElementById("someDiv").appendChild(iframe);
            }
          }
        })
        
      },
      yes:function (index, layero) {
        fnBase.ajaxJson({
          type: "get",
          url: '/goldnet-enterprise-client/comm/file/down',
          data: { fileId: option.fileId },
          success: function (response) {
            var url = response.data.fileLink
            fnBase.download(url)
          }
        });
        return false
      }
    });
    

  },



  /**
   * @name: pdf预览相关
   * @test: test font
   * @msg:
   * @param {*}
   * @return {*}
   */

  //打开服务pdf文件
  _openWebFile: function (PDFCtrl, url) {
    try {
      PDFCtrl.OpenWebFile(url);
    } catch (e) {
      var LastErrorDesc = PDFCtrl.GetLastErrorDesc();
      alert(LastErrorDesc);
    }
  },
  // 判断是否按安装软件
  downloadPDF: function () {
    try {
      PDFAgent = document.all.PDFCtrlBak.object;
      return PDFAgent;
    } catch (e) {
      return false;
    }
  },
  //下载软件
  downloadFile: function (url) {
    var url = url
    var form = $("<form>");
    form.attr("style", "display:none");
    form.attr("method", "get");
    form.attr("action", url);
    $("body").append(form);//将表单放置在web中
    form.submit();//表单提交
  },
  // pdf预览
  pdfView: function (title, url) {
    // 先判断浏览器  IE
    var layer = layui.layer
    var PDFCtrlBak = {}
    if (
      navigator.appName.indexOf('Internet') >= 0 ||
      navigator.appVersion.indexOf('Trident') >= 0
    ) {

      layer.open({
        title: title,
        offset: '50px',
        type: 0,
        skin: 'footBtn-box',
        content: '<div id="viewDetail" style="width:800px;height:400px;"></div>', //这里content是一个普通的String
        btn: ['下载'],
        yes: function (index, layero) {
          //按钮【按钮一】的回调
          fnBase.download(url)
        },
        success: function () {
          var str = fnBase.getUrlBak()
          var container = document.getElementById('viewDetail');
          container.innerHTML = str
          if (!fnBase.downloadPDF()) {
            layer.closeAll()
            layer.confirm('请下载安装PDF插件后刷新页面！', {
              btn: ['下载', '取消'] //按钮
            }, function () {
              layer.closeAll()
              fnBase.downloadFile('/avic/exe/TrustSignPDFPlugin.Standard.exe')
            });
            return
          }
          PDFCtrlBak = document.querySelector('#PDFCtrlBak')
          fnBase._openWebFile(PDFCtrlBak, url)

        }
      })
    } else {
      //非IE浏览器
      layer.open({
        title: title,
        offset: '50px',
        type: 0,
        skin: 'footBtn-box',
        content:
          '<div id="viewDetail" style="width:800px;height:400px;"></div>', //这里content是一个普通的String
        btn: ['下载'],
        yes: function (index, layero) {
          //按钮【按钮一】的回调
          fnBase.download(url)
        },
        success: function () {
          var options = {
            pdfOpenParams: {
              pagemode: 'thumbs',
              navpanes: 0,
              toolbar: 0,
              statusbar: 0,
              //view: "FitV"
            },
          }
          PDFObject.embed(url, '#viewDetail', options)
        }
      })

    }
  },

  //实名认证pdf预览不带下载
  pdfOnlyView: function (title, url) {
    // 先判断浏览器  IE
    var layer = layui.layer
    var PDFCtrlBak = {}
    if (
      navigator.appName.indexOf('Internet') >= 0 ||
      navigator.appVersion.indexOf('Trident') >= 0
    ) {
      var str = fnBase.getUrlBak()
      layer.open({
        title: title,
        area: ['auto', '95%'],
        skin: 'footBtn-box',
        type: 0,
        content: '<div id="viewDetail" style="width:1000px;height:100%;"></div>', //这里content是一个普通的String
        success: function () {
          var str = fnBase.getUrlBak()
          var container = document.getElementById('viewDetail');
          container.innerHTML = str
          if (!fnBase.downloadPDF()) {
            layer.closeAll()
            layer.confirm('请下载安装PDF插件后刷新页面！', {
              btn: ['下载', '取消'] //按钮
            }, function () {
              layer.closeAll()
              fnBase.downloadFile('/avic/exe/TrustSignPDFPlugin.Standard.exe')
            });
            return
          }
          PDFCtrlBak = document.querySelector('#PDFCtrlBak')
          fnBase._openWebFile(PDFCtrlBak, url)

        }
      })
    } else {
      //非IE浏览器
      layer.open({
        title: title,
        area: ['auto', '95%'],
        skin: 'footBtn-box',
        type: 0,
        content:
          '<div id="viewDetail" style="width:1000px;height:100%;"></div>', //这里content是一个普通的String
        success: function () {
          var options = {
            pdfOpenParams: {
              pagemode: 'thumbs',
              navpanes: 0,
              toolbar: 0,
              statusbar: 0,
              //view: "FitV"
            },
          }
          PDFObject.embed(url, '#viewDetail', options)
        }
      })

    }
  },
  // ie下预览
  getUrlBak: function () { 
    if (
      navigator.appName.indexOf('Internet') >= 0 ||
      navigator.appVersion.indexOf('Trident') >= 0
    ) {
      if (window.navigator.cpuClass == 'x86') {
        var str =
          '<object id="PDFCtrlBak" codebase="TrustSignPDFPlugin.Standard.x86.cab#version=3,2,0,9"' +
          'classid="clsid:6F60FE31-F827-4295-8AC4-775EF7478A6A" width="100%" height="100%"><param name="showToolbar" value=false></object>'
        return str
      } else {
        var str1 =
          '<object id="PDFCtrlBak" codebase="TrustSignPDFPlugin.Standard.x64.cab#version=3,2,0,9"' +
          'classid="clsid:6F60FE31-F827-4295-8AC4-775EF7478A6A" width="100%" height="100%"><param name="showToolbar" value=false></object>'
        return str1
      }
    } else {
      alert('为保证系统正常使用，请使用IE8版本及以上的浏览器进行访问!')
      return false
    }
  },



  //ukey相关操作
  checkUkeyParam: function (ukey) {
    var flag = true
    return flag
  },
  //判断ukey是否已被当前用户使用
  hasUsedCode: function (ukeyNum1, ukeyNum2) {

    if (ukeyNum1 != "" && ukeyNum2 != "") {
      if (ukeyNum1 == ukeyNum2) {
        return true;
      }
    }
    return false;
  },
  // ukey绑定方法
  ukeyBing: function (bankType, bankTips, bankName) {
    var index = 3
    setCookie('bankTips', bankTips)
    setCookie('bankType', bankType)
    setCookie('bankName', bankName)
    bindBankUkeyProc = fnBase.getBindUkeyBank(bankType)
    var authEnterprise = ''
    bindBankUkeyProc.ukeyBing(authEnterprise, index)
  },
  //获取绑定的ukey类型
  getBindUkeyBank: function (bankType) {
    //建行或者CFCA的ukey
    if (
      BANK_TYPE_CCB == bankType ||
      BANK_TYPE_CMBC == bankType ||
      BANK_TYPE_BOC == bankType ||
      BANK_TYPE_CIB == bankType ||
      BANK_TYPE_CITICIB == bankType ||
      BANK_TYPE_HB == bankType ||
      BANK_TYPE_CFCA == bankType
    ) {
      bindBankUkeyProc = new JSYHClass()
      bindBankUkeyProc.regisAuthBankProc = regisAuthBankProc
      bindBankUkeyProc.initWidget()
      return bindBankUkeyProc
    }
    //工商银行
    if (BANK_TYPE_ICBC == bankType) {
      bindBankUkeyProc = new GSYHClass()
      bindBankUkeyProc.regisAuthBankProc = regisAuthBankProc
      bindBankUkeyProc.initWidget()
      return bindBankUkeyProc
    }
    //实名绑定ukkey交行模式
    //交通银行

    if (BANK_TYPE_JTYH == bankType) {

      //bindBankUkeyProc = new regisAuthBankBackV2EndClass();
      var bindBankUkeyProc = new JTYHClass()
      bindBankUkeyProc.regisAuthBankProc = regisAuthBankProc
      bindBankUkeyProc.initWidget()
      return bindBankUkeyProc
    }

    bindBankUkeyProc = new regisAuthBankFrontEndClass()
    bindBankUkeyProc.regisAuthBankProc = regisAuthBankProc
    bindBankUkeyProc.initWidget()
    return bindBankUkeyProc
  },




  /**
  * @name: fnBase 公共方法
  * @test: test font
  * @msg:
  * @param {*}
  * @return {*}
  */
  getTime: function (nS) {
    //时间戳转换
    var val = parseInt(nS) > 10000000000 ? parseInt(nS) : parseInt(nS) * 1000
    var time = new Date(val)
    var oY = time.getFullYear()
    var oM = time.getMonth() + 1
    var oD = time.getDate()

    var str =
      oY + '-' + (oM > 9 ? oM : '0' + oM) + '-' + (oD > 9 ? oD : '0' + oD)
    return str
  },
  //图片替换,清晰图片替换模糊图片
  photoReplace: function (uri, ele) {
    var img = new Image()
    img.src = uri
    img.onload = function () {
      $('#' + ele).attr('src', uri)
    }
  },
  goLogin: function () {
    window.location.href = '/gongyinglian/login.jsp'
  },
  

  formatDate: function (date, fmt) {
    // 拼配fmt中的一个或多个y字符
    if (/(y+)/.test(fmt)) { // 匹配成功
      // RegExp.$1是匹配的y字符（'yyyy'）, 用时间的年份替换
      fmt = fmt.replace(RegExp.$1, (date.getFullYear() + '').substr(4 - RegExp.$1.length)); // substr() 方法可在字符串中抽取从 start 下标开始的指定数目的字符。
    };
    var o = {
      'M+': date.getMonth() + 1, // getMouth()获取的月份是从0~11,按习惯+1
      'd+': date.getDate(),
      'h+': date.getHours(),
      'm+': date.getMinutes(),
      's+': date.getSeconds()
    };
    for (var key in o) {
      if (new RegExp("(" + key + ")").test(fmt)) {
        var str = o[key] + ''; // 时间对象对应的真实数字，转为字符串 + ‘’
        // 将字符串的MM dd hh mm 替换掉
        fmt = fmt.replace(RegExp.$1, (RegExp.$1.length === 1) ? str : fnBase.padLeftZero(str));
      }
    }
    return fmt;
  },
  // 补0
  padLeftZero: function (st) {
    return ('00' + st).substr(st.length);
  },
  numFormat: function (num) {
    try {
      var res = num.toString().replace(/\d+/, function (n) { // 先提取小数点前后的整数部分
        //(\d)(?=(\d{3})正则的意思是匹配连续三个数结尾的数字，例如1234，1后面有234连续三个数的数字，就可以匹配上，匹配的是1这个数字。如果是123，因为1后面是两位数，所以就匹配不上了
        return n.replace(/(\d)(?=(\d{3})+$)/g, function ($1) {
          return $1 + ",";
        });
      })
      return res;
    } catch (error) {
      return ''
    }

  },
  // 相似度
  similar: function(s, t, f) {
    if (!s || !t) {
      return 0
    }
    if(s === t){
      return 100;
    }
    var l = s.length > t.length ? s.length : t.length
    var n = s.length
    var m = t.length
    var d = []
    f = f || 2
    var min = function (a, b, c) {
      return a < b ? (a < c ? a : c) : (b < c ? b : c)
    }
    var i, j, si, tj, cost
    if (n === 0) return m
    if (m === 0) return n
    for (i = 0; i <= n; i++) {
      d[i] = []
      d[i][0] = i
    }
    for (j = 0; j <= m; j++) {
      d[0][j] = j
    }
    for (i = 1; i <= n; i++) {
      si = s.charAt(i - 1)
      for (j = 1; j <= m; j++) {
        tj = t.charAt(j - 1)
        if (si === tj) {
          cost = 0
        } else {
          cost = 1
        }
        d[i][j] = min(d[i - 1][j] + 1, d[i][j - 1] + 1, d[i - 1][j - 1] + cost)
      }
    }
    var res = (1 - d[n][m] / l) *100
    return res.toFixed(f)
  },
  //RSA加密
  rsaSigin:function (pas) {
      var encryptor = new JSEncrypt()  // 创建加密对象实例
      //之前生成的公钥，复制的时候要小心不要有空格(此处把密钥省略了，自己写的时候可把自己生成的公钥粘到对应位置)
      var pubKey = 'MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA2EOrSPZAbBplD1D4ettGqvR/FKT0a/Jqt4nBOfegvZmP3Ddmfxv731+HckjxAZCBjlcg7aX5E2Z5sXIHsYAK2HXGFuE3yhIqrfjThvAfDNzwXSzPvo30nWiOSJmAhqiFSjUOjjNILI1Hhbk1PsEDslr+15MwaxPWT3VOb2JMJSRjyebF+x5nZCedanJlT15xiyw0jZ+HumwIl1bxv1/XnVnuevN8kuBHC1EZid94r5IYCwUnNXiP+kPLg2O4B+aGOFa/+dYtgeMqOMNe8phgKFtMpbmi+rMYDLinsWSph87x0POPpHNOAGkhgZ2sNtyg1hb7ocSEimCArLURXPFXfQIDAQAB'
      encryptor.setPublicKey(pubKey)//设置公钥
      var rsaPassWord = encryptor.encrypt(pas)  // 对内容进行加密
      return rsaPassWord
  }

}
fnBase.init()


/**
 * commom方法
 * 
 */
// 生成uuid
var createUUID = (function (uuidRegEx, uuidReplacer) {
  return function () {
    return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'
      .replace(uuidRegEx, uuidReplacer)
      .toUpperCase()
  }
})(/[xy]/g, function (c) {
  var r = (Math.random() * 16) | 0,
    v = c == 'x' ? r : (r & 3) | 8
  return v.toString(16)
})
// 获取url参数
function GetRequest() {
  var url = location.search // 获取url中"?"符后的字串
  var theRequest = new Object()
  if (url.indexOf('?') != -1) {
    var str = url.substr(1)
    var strs = str.split('&')
    for (var i = 0; i < strs.length; i++) {
      theRequest[strs[i].split('=')[0]] = decodeURIComponent(
        strs[i].split('=')[1]
      )
    }
  }
  return theRequest
}
function IsPicture(url) {
  //判断是否是图片 - strFilter必须是小写列举
  var strFilter = '.jpeg|.gif|.jpg|.png|.bmp|.pic|'
  if (url.indexOf('.') > -1) {
    var p = url.lastIndexOf('.')
    //alert(p);
    //alert(url.length);
    var strPostfix = url.substring(p, url.length) + '|'
    strPostfix = strPostfix.toLowerCase()
    //alert(strPostfix);
    if (strFilter.indexOf(strPostfix) > -1) {
      //alert("True");
      return true
    }
  }
  //alert('False');
  return false
}
function IEVersion() {
  //取得浏览器的userAgent字符串
  var userAgent = navigator.userAgent
  //判断是否IE浏览器
  var isIE =
    userAgent.indexOf('compatible') > -1 && userAgent.indexOf('MSIE') > -1
  if (isIE) {
    var reIE = new RegExp('MSIE (\\d+\\.\\d+);')
    reIE.test(userAgent)
    var fIEVersion = parseFloat(RegExp['$1'])
    if (fIEVersion < 10 || !isSupportPlaceholder()) {
      return true
    }
  } else {
    return false
  }
}
//表单序列化获取未选中的CheckBox
$.fn.serializeJson = function () {
  var serializeObj = {}
  var temp = this.serializeArray()
  var not_checked_object = $('input[type=checkbox]:not(:checked)', this)
  $.each(not_checked_object, function () {
    if (!temp.hasOwnProperty(this.name)) {
      //this指没选中的一个object
      temp.push({ name: this.name, value: '' })
    }
  })
  $(temp).each(function () {
    //将有相通name的CheckBox合并到一个数组中
    if (serializeObj[this.name]) {
      if ($.isArray(serializeObj[this.name])) {
        serializeObj[this.name].push(this.value)
      } else {
        serializeObj[this.name] = [serializeObj[this.name], this.value]
      }
    } else {
      serializeObj[this.name] = this.value
    }
  })
  return serializeObj
}


// 去除前后空格
function myTrim(str) {
  if (String.prototype.trim) {
    return str.trim()
  } else {
    return str.replace(/^\s+|\s+$/g, '')
  }
}

//查重
function CheckAgain(arr1, arr2) {
  var a = false;
  if (arr1.length !== 0 && JSON.stringify(arr2) !== "{}") {
    $.each(arr1, function (index, item) {
      $.each(arr2, function (i, e) {
        if (item.enterpriseName === e.enterpriseName) {
          a = true;
        }
      })
    })
    return a;
  } else {
    return a;
  }

}
//单数据查重
function CheckElement(arr1, element) {
  var a = false;
  if (arr1.length !== 0 && JSON.stringify(element) !== "{}") {
    $.each(arr1, function (index, item) {
      if (item.enterpriseName === element.enterpriseName) {
        a = true;
      }
    })
    return a;
  } else {
    return a;
  }
}
//显示刚刚,小时,周
function dateShow(date) {
  var dateTimeStamp = Date.parse(date.replace(/-/gi, "/"));
  var minute = 1000 * 60;
  var hour = minute * 60;
  var day = hour * 24;
  var halfamonth = day * 15;
  var month = day * 30;
  var now = new Date().getTime();
  var diffValue = now - dateTimeStamp;
  if (diffValue < 0) {
    //若日期不符则弹窗口告之,结束日期不能小于开始日期！
  }
  var monthC = diffValue / month;
  var weekC = diffValue / (7 * day);
  var dayC = diffValue / day;
  var hourC = diffValue / hour;
  var minC = diffValue / minute;
  if (monthC >= 1) {
    result = date;
  }
  else if (weekC >= 1) {
    result = date;
  }
  else if (dayC >= 1) {
    result = parseInt(dayC) + "天前";
  }
  else if (hourC >= 1) {
    result = parseInt(hourC) + "个小时前";
  }
  else if (minC >= 1) {
    result = parseInt(minC) + "分钟前";
  } else
    result = "刚刚发表";
  return result;
}

/**
 * cookie相关操作
 * 
 */
//设置cookie
function setCookie(name, value) {
  try {
    document.cookie = name + '=' + escape(value) + '; path=/'
  } catch (error) {

  }

  return
  if (name === 'userInfo') {
    try {
      var obj = JSON.parse(value)
      obj['user_name'] = escape(obj['user_name'] || '')
      obj['enterpriseName'] = escape(obj['enterpriseName'] || '')
      document.cookie = name + '=' + JSON.stringify(obj) + '; path=/'
    } catch (error) {

    }

  } else {
    document.cookie = name + '=' + value + '; path=/'
  }

}
// 获取指定名称的cookie
function getCookie(name) {
  var strcookie = document.cookie //获取cookie字符串
  var arrcookie = strcookie.split('; ') //分割
  //遍历匹配
  for (var i = 0; i < arrcookie.length; i++) {
    var arr = arrcookie[i].split('=')
    if (arr[0] == name) {
      return unescape(arr[1])
      // if(name === 'userInfo'){
      //   try {
      //     var obj=JSON.parse(arr[1])
      //     obj['user_name'] = unescape(obj['user_name']||'')
      //     obj['enterpriseName'] = unescape(obj['enterpriseName']||'')
      //     return JSON.stringify(obj)
      //   } catch (error) {
      //     return ''
      //   }

      // }else{
      //   return arr[1]
      // }

    }
  }
  return ''
}
//清除所有cookie函数
function clearAllCookie() {
  var keys = document.cookie.match(/[^ =;]+(?=\=)/g)
  if (keys) {
    if (keys.length) {
      for (var i = 0; i < keys.length; i++) {
        setCookie(keys[i], "", -1);
      }
    }
  }
}




/**
 * IE兼容的一些方法
 * 
 */
// 判断浏览器是否支持placeholder属性
function isSupportPlaceholder() {
  var input = document.createElement('input')
  return 'placeholder' in input
}
//解决IE10以下不支持Function.bind
if (!Function.prototype.bind) {
  Function.prototype.bind = function (oThis) {
    if (typeof this !== "function") {
      throw new TypeError("Function.prototype.bind - what is trying to be bound is not callable");
    }
    var aArgs = Array.prototype.slice.call(arguments, 1),
      fToBind = this,
      fNOP = function () { },
      fBound = function () {
        return fToBind.apply(this instanceof fNOP && oThis ? this : oThis,
          aArgs.concat(Array.prototype.slice.call(arguments)));
      };
    fNOP.prototype = this.prototype;
    fBound.prototype = new fNOP();
    return fBound;
  };
}

//IE8兼容isArray
if (!Array.isArray) {
  Array.isArray = function (obj) {
    return Object.prototype.toString.call(obj) == '[object Array]'
  }
}

// ie8兼容object.keys
if (!Object.keys) {
  Object.keys = (function () {
    var hasOwnProperty = Object.prototype.hasOwnProperty,
      hasDontEnumBug = !{ toString: null }.propertyIsEnumerable('toString'),
      dontEnums = [
        'toString',
        'toLocaleString',
        'valueOf',
        'hasOwnProperty',
        'isPrototypeOf',
        'propertyIsEnumerable',
        'constructor',
      ],
      dontEnumsLength = dontEnums.length

    return function (obj) {
      if (
        (typeof obj !== 'object' && typeof obj !== 'function') ||
        obj === null
      )
        throw new TypeError('Object.keys called on non-object')

      var result = []

      for (var prop in obj) {
        if (hasOwnProperty.call(obj, prop)) result.push(prop)
      }

      if (hasDontEnumBug) {
        for (var i = 0; i < dontEnumsLength; i++) {
          if (hasOwnProperty.call(obj, dontEnums[i])) result.push(dontEnums[i])
        }
      }
      return result
    }
  })()
}
// ie8兼容indexOf
if (!Array.indexOf) {
  Array.prototype.indexOf = function (obj) {
    for (var i = 0; i < this.length; i++) {
      if (this[i] == obj) {
        return i;
      }
    }
    return -1;
  }
}
if (!Array.prototype.forEach) {

  Array.prototype.forEach = function (callback/*, thisArg*/) {

    var T, k;

    if (this == null) {
      throw new TypeError('this is null or not defined');
    }

    // 1. Let O be the result of calling toObject() passing the
    // |this| value as the argument.
    var O = Object(this);

    // 2. Let lenValue be the result of calling the Get() internal
    // method of O with the argument "length".
    // 3. Let len be toUint32(lenValue).
    var len = O.length >>> 0;

    // 4. If isCallable(callback) is false, throw a TypeError exception. 
    // See: http://es5.github.com/#x9.11
    if (typeof callback !== 'function') {
      throw new TypeError(callback + ' is not a function');
    }

    // 5. If thisArg was supplied, let T be thisArg; else let
    // T be undefined.
    if (arguments.length > 1) {
      T = arguments[1];
    }

    // 6. Let k be 0.
    k = 0;

    // 7. Repeat while k < len.
    while (k < len) {

      var kValue;

      // a. Let Pk be ToString(k).
      //    This is implicit for LHS operands of the in operator.
      // b. Let kPresent be the result of calling the HasProperty
      //    internal method of O with argument Pk.
      //    This step can be combined with c.
      // c. If kPresent is true, then
      if (k in O) {

        // i. Let kValue be the result of calling the Get internal
        // method of O with argument Pk.
        kValue = O[k];

        // ii. Call the Call internal method of callback with T as
        // the this value and argument list containing kValue, k, and O.
        callback.call(T, kValue, k, O);
      }
      // d. Increase k by 1.
      k++;
    }
    // 8. return undefined.
  };
}



$(function () {
  //headerConfig()
  headerRegConfig()
})
function headerConfig() {
  var url = window.location.href
  if (url.indexOf('/avic/reg/certification') == -1 && url.indexOf('/avic/reg/auth') == -1 && url.indexOf('/avic/reg/federatedLogin') == -1 && url.indexOf('/avic/reg/examine') == -1) {
    $('#leftMenu').show()
    $('#rightWrapper').css('margin-left', '268px')
    $('#app-headerOther').hide()
    $('#app-header').show()
  } else {
    $('#leftMenu').hide()
    $('#rightWrapper').css('margin-left', '0')
    $('#app-headerOther').show()
    $('#app-header').hide()
  }
}
function headerRegConfig() {
  var url = window.location.href
  if (url.indexOf('/avic/reg/setPsw') != -1) {
    $('#reg_titleName').text('设置密码')
    $('#reg_header_login').hide()
  } else {
    $('#reg_titleName').text('账号注册')
    $('#reg_header_login').show()
  }
}
//解决IE10以下不支持Function.bind
if (!Function.prototype.bind) {
  Function.prototype.bind = function (oThis) {
    if (typeof this !== "function") {
      throw new TypeError("Function.prototype.bind - what is trying to be bound is not callable");
    }
    var aArgs = Array.prototype.slice.call(arguments, 1),
      fToBind = this,
      fNOP = function () { },
      fBound = function () {
        return fToBind.apply(this instanceof fNOP && oThis ? this : oThis,
          aArgs.concat(Array.prototype.slice.call(arguments)));
      };
    fNOP.prototype = this.prototype;
    fBound.prototype = new fNOP();
    return fBound;
  };
}
//格式化金额的小数点
function subNumber(value) {
  var b = false;

  if (value === null || value === "") {
    return "";
  } else if (value === 0) {
    return value;
  }
  value = value.toString();
  if (value.indexOf('-') != -1) {
    b = true;
    value = value.substring(1, value.length);
  }
  if (/^\-?[0-9]+(.[0-9]+)?$/.test(value)) {
    value = value.toString().replace(/^(\d*)$/, "$1.");
    value = (value + "00").replace(/(\d*\.\d\d)\d*/, "$1");
    value = value.replace(".", ",");
    var re = /(\d)(\d{3},)/;
    while (re.test(value))
      value = value.replace(re, "$1,$2");
    value = value.replace(/,(\d\d)$/, ".$1");
  }
  if (b) {
    value = "-" + value;
  }
  return value;
}

//分转成元
function regFenToYuan(fen) {
  if (fen === null || fen === "") {
    return ''
  } else {
    var num = Number(fen) / 100;
    return num
  }
}

//元转分
function regYuanToFen(yuan) {
  var money = Number(yuan) * 100
  return money
}

//用于搜索栏里的金额转换
function regYuanToFenSearch(yuan) {
  if (yuan == '' || yuan == null) {
    return ''
  } else {
    var money = Number(yuan) * 100
    return String(money)
  }
}

/*处理时间基础方法*/
var dayjs = function(){

    function format (){
        var date = new Date()
        var year = date.getFullYear()
        var month = (date.getMonth() + 1) > 9 ? (date.getMonth() + 1) : '0' + (date.getMonth() + 1)
        var day = date.getDate() > 9 ? date.getDate() : '0' + date.getDate()
        return year + '-' + month + '-' + day
    }
    function diff (strDateStart,strDateEnd){
        // debugger
        var strSeparator = "-"; //日期分隔符
        var oDate1;
        var oDate2;
        var iDays;
        oDate1= strDateStart.split(strSeparator);
        oDate2= strDateEnd.split(strSeparator);
        var strDateS = new Date(oDate1[0], oDate1[1]-1, oDate1[2]);
        var strDateE = new Date(oDate2[0], oDate2[1]-1, oDate2[2]);
        iDays = parseInt(Math.abs(strDateS - strDateE ) / 1000 / 60 / 60 /24)//把相差的毫秒数转换为天数 
      return iDays?iDays:'';
    }

    return {
        format:format,
        diff:diff
    }
};//bugfix 不要删除分号 需要打包
//download.js v4.2, by dandavis; 2008-2016. [CCBY2] see http://danml.com/download.html for tests/usage
// v1 landed a FF+Chrome compat way of downloading strings to local un-named files, upgraded to use a hidden frame and optional mime
// v2 added named files via a[download], msSaveBlob, IE (10+) support, and window.URL support for larger+faster saves than dataURLs
// v3 added dataURL and Blob Input, bind-toggle arity, and legacy dataURL fallback was improved with force-download mime and base64 support. 3.1 improved safari handling.
// v4 adds AMD/UMD, commonJS, and plain browser support
// v4.1 adds url download capability via solo URL argument (same domain/CORS only)
// v4.2 adds semantic variable names, long (over 2MB) dataURL support, and hidden by default temp anchors
// https://github.com/rndme/download

(function (root, factory) {
	if (typeof define === 'function' && define.amd) {
		// AMD. Register as an anonymous module.
		define([], factory);
	} else if (typeof exports === 'object') {
		// Node. Does not work with strict CommonJS, but
		// only CommonJS-like environments that support module.exports,
		// like Node.
		module.exports = factory();
	} else {
		// Browser globals (root is window)
		root.download = factory();
  }
}(this, function () {

	return function download(data, strFileName, strMimeType) {

		var self = window, // this script is only for browsers anyway...
			defaultMime = "application/octet-stream", // this default mime also triggers iframe downloads
			mimeType = strMimeType || defaultMime,
			payload = data,
			url = !strFileName && !strMimeType && payload,
			anchor = document.createElement("a"),
			toString = function(a){return String(a);},
			myBlob = (self.Blob || self.MozBlob || self.WebKitBlob || toString),
			fileName = strFileName || "download",
			blob,
			reader;
			myBlob= myBlob.call ? myBlob.bind(self) : Blob ;
	  
		if(String(this)==="true"){ //reverse arguments, allowing download.bind(true, "text/xml", "export.xml") to act as a callback
			payload=[payload, mimeType];
			mimeType=payload[0];
			payload=payload[1];
		}


		if(url && url.length< 2048){ // if no filename and no mime, assume a url was passed as the only argument
			fileName = url.split("/").pop().split("?")[0];
			anchor.href = url; // assign href prop to temp anchor
		  	if(anchor.href.indexOf(url) !== -1){ // if the browser determines that it's a potentially valid url path:
        		var ajax=new XMLHttpRequest();
        		ajax.open( "GET", url, true);
        		ajax.responseType = 'blob';
        		ajax.onload= function(e){ 
				  download(e.target.response, decodeURI(fileName), defaultMime);
				};
        		setTimeout(function(){ ajax.send();}, 0); // allows setting custom ajax headers using the return:
			    return ajax;
			} // end if valid url?
		} // end if url?


		//go ahead and download dataURLs right away
		if(/^data\:[\w+\-]+\/[\w+\-]+[,;]/.test(payload)){
		
			if(payload.length > (1024*1024*1.999) && myBlob !== toString ){
				payload=dataUrlToBlob(payload);
				mimeType=payload.type || defaultMime;
			}else{			
				return navigator.msSaveBlob ?  // IE10 can't do a[download], only Blobs:
					navigator.msSaveBlob(dataUrlToBlob(payload), decodeURI(fileName)) :
					saver(payload) ; // everyone else can save dataURLs un-processed
			}
			
		}//end if dataURL passed?

		blob = payload instanceof myBlob ?
			payload :
			new myBlob([payload], {type: mimeType}) ;


		function dataUrlToBlob(strUrl) {
			var parts= strUrl.split(/[:;,]/),
			type= parts[1],
			decoder= parts[2] == "base64" ? atob : decodeURIComponent,
			binData= decoder( parts.pop() ),
			mx= binData.length,
			i= 0,
			uiArr= new Uint8Array(mx);

			for(i;i<mx;++i) uiArr[i]= binData.charCodeAt(i);

			return new myBlob([uiArr], {type: type});
		 }

		function saver(url, winMode){

			if ('download' in anchor) { //html5 A[download]
				anchor.href = url;
				anchor.setAttribute("download", decodeURI(fileName));
				anchor.className = "download-js-link";
				anchor.innerHTML = "downloading...";
				anchor.style.display = "none";
				document.body.appendChild(anchor);
				setTimeout(function() {
					anchor.click();
					document.body.removeChild(anchor);
					if(winMode===true){setTimeout(function(){ self.URL.revokeObjectURL(anchor.href);}, 250 );}
				}, 66);
				return true;
			}

			// handle non-a[download] safari as best we can:
			if(/(Version)\/(\d+)\.(\d+)(?:\.(\d+))?.*Safari\//.test(navigator.userAgent)) {
				url=url.replace(/^data:([\w\/\-\+]+)/, defaultMime);
				if(!window.open(url)){ // popup blocked, offer direct download:
					if(confirm("Displaying New Document\n\nUse Save As... to download, then click back to return to this page.")){ location.href=url; }
				}
				return true;
			}

			//do iframe dataURL download (old ch+FF):
			var f = document.createElement("iframe");
			document.body.appendChild(f);

			if(!winMode){ // force a mime that will download:
				url="data:"+url.replace(/^data:([\w\/\-\+]+)/, defaultMime);
			}
			f.src=url;
			setTimeout(function(){ document.body.removeChild(f); }, 333);

		}//end saver




		if (navigator.msSaveBlob) { // IE10+ : (has Blob, but not a[download] or URL)
			return navigator.msSaveBlob(blob, decodeURI(fileName));
		}

		if(self.URL){ // simple fast and modern way using Blob and URL:
			saver(self.URL.createObjectURL(blob), true);
		}else{
			// handle non-Blob()+non-URL browsers:
			if(typeof blob === "string" || blob.constructor===toString ){
				try{
					return saver( "data:" +  mimeType   + ";base64,"  +  self.btoa(blob)  );
				}catch(y){
					return saver( "data:" +  mimeType   + "," + encodeURIComponent(blob)  );
				}
			}

			// Blob but not URL support:
			reader=new FileReader();
			reader.onload=function(e){
				saver(this.result);
			};
			reader.readAsDataURL(blob);
		}
		return true;
	}; /* end download() */
}));
/*
 * @Descripttion: layui自动化表单验证
 * @Author: whyjs
 * @Date: 2022-07-27 11:17:21
 * @LastEditors: whyjs
 * @LastEditTime: 2023-03-16 11:35:05
 */
var LayuiFormValidation = function () {
  var idCardNoUtil = {

    /* 省,直辖市代码表 */
    provinceAndCitys: {
        11: "北京",
        12: "天津",
        13: "河北",
        14: "山西",
        15: "内蒙古",
        21: "辽宁",
        22: "吉林",
        23: "黑龙江",
        31: "上海",
        32: "江苏",
        33: "浙江",
        34: "安徽",
        35: "福建",
        36: "江西",
        37: "山东",
        41: "河南",
        42: "湖北",
        43: "湖南",
        44: "广东",
        45: "广西",
        46: "海南",
        50: "重庆",
        51: "四川",
        52: "贵州",
        53: "云南",
        54: "西藏",
        61: "陕西",
        62: "甘肃",
        63: "青海",
        64: "宁夏",
        65: "新疆",
        71: "台湾",
        81: "香港",
        82: "澳门",
        99: "其他"
    },

    /* 每位加权因子 */
    powers: ["7", "9", "10", "5", "8", "4", "2", "1", "6", "3", "7", "9", "10", "5", "8", "4", "2"],

    /* 第18位校检码 */
    parityBit: ["1", "0", "X", "9", "8", "7", "6", "5", "4", "3", "2"],

    /* 性别 */
    genders: {
        male: "男",
        female: "女"
    },

    /* 校验地址码 */
    checkAddressCode: function (addressCode) {
        var check = /^[1-9]\d{5}$/.test(addressCode);
        if (!check)
            return false;
        if (idCardNoUtil.provinceAndCitys[parseInt(addressCode.substring(0, 2))]) {
            return true;
        } else {
            return false;
        }
    },

    /* 校验日期码 */
    checkBirthDayCode: function (birDayCode) {
        var check = /^[1-9]\d{3}((0[1-9])|(1[0-2]))((0[1-9])|([1-2][0-9])|(3[0-1]))$/.test(birDayCode);
        if (!check)
            return false;
        var yyyy = parseInt(birDayCode.substring(0, 4), 10);
        var mm = parseInt(birDayCode.substring(4, 6), 10);
        var dd = parseInt(birDayCode.substring(6), 10);
        var xdata = new Date(yyyy, mm - 1, dd);
        if (xdata > new Date()) {
            return false;// 生日不能大于当前日期
        } else if ((xdata.getFullYear() == yyyy) && (xdata.getMonth() == mm - 1) && (xdata.getDate() == dd)) {
            return true;
        } else {
            return false;
        }
    },

    /* 计算校检码 */
    getParityBit: function (idCardNo) {
        var id17 = idCardNo.substring(0, 17);
        /* 加权 */
        var power = 0;
        for (var i = 0; i < 17; i++) {
            power += parseInt(id17.charAt(i), 10) * parseInt(idCardNoUtil.powers[i]);
        }
        /* 取模 */
        var mod = power % 11;
        return idCardNoUtil.parityBit[mod];
    },

    /* 验证校检码 */
    checkParityBit: function (idCardNo) {
        var parityBit = idCardNo.charAt(17).toUpperCase();
        if (idCardNoUtil.getParityBit(idCardNo) == parityBit) {
            return true;
        } else {
            return false;
        }
    },

    /* 校验15位或18位的身份证号码 */
    checkIdCardNo: function (idCardNo) {
        // 99开头的不校验
        if (idCardNo.indexOf("99") === 0) {
            return true;
        }
        // 15位和18位身份证号码的基本校验
        var check = /^\d{15}|(\d{17}(\d|x|X))$/.test(idCardNo);
        if (!check)
            return false;
        // 判断长度为15位或18位
        if (idCardNo.length == 15) {
            return idCardNoUtil.check15IdCardNo(idCardNo);
        } else if (idCardNo.length == 18) {
            return idCardNoUtil.check18IdCardNo(idCardNo);
        } else {
            return false;
        }
    },

    // 校验15位的身份证号码
    check15IdCardNo: function (idCardNo) {
        // 15位身份证号码的基本校验
        var check = /^[1-9]\d{7}((0[1-9])|(1[0-2]))((0[1-9])|([1-2][0-9])|(3[0-1]))\d{3}$/.test(idCardNo);
        if (!check)
            return false;
        // 校验地址码
        var addressCode = idCardNo.substring(0, 6);
        check = idCardNoUtil.checkAddressCode(addressCode);
        if (!check)
            return false;
        var birDayCode = '19' + idCardNo.substring(6, 12);
        // 校验日期码
        return idCardNoUtil.checkBirthDayCode(birDayCode);
    },

    // 校验18位的身份证号码
    check18IdCardNo: function (idCardNo) {
        // 18位身份证号码的基本格式校验
        var check = /^[1-9]\d{5}[1-9]\d{3}((0[1-9])|(1[0-2]))((0[1-9])|([1-2][0-9])|(3[0-1]))\d{3}(\d|x|X)$/.test(idCardNo);
        if (!check)
            return false;
        // 校验地址码
        var addressCode = idCardNo.substring(0, 6);
        check = idCardNoUtil.checkAddressCode(addressCode);
        if (!check)
            return false;
        // 校验日期码
        var birDayCode = idCardNo.substring(6, 14);
        check = idCardNoUtil.checkBirthDayCode(birDayCode);
        if (!check)
            return false;
        // 验证校检码
        // return idCardNoUtil.checkParityBit(idCardNo);
        return check;
    },

    formateDateCN: function (day) {
        if (idCardNoUtil.checkBirthDayCode(day)) {
            var yyyy = day.substring(0, 4);
            var mm = day.substring(4, 6);
            var dd = day.substring(6);
            // alert(yyyy + '-' + mm +'-' + dd);
            return yyyy + '-' + mm + '-' + dd;
        }
        return "";
    },

    // 获取信息
    getIdCardInfo: function (idCardNo) {
        var idCardInfo = {
            gender: "", // 性别
            birthday: "" // 出生日期(yyyy-mm-dd)
        };
        if (idCardNo.length == 15) {
            var aday = '19' + idCardNo.substring(6, 12);
            idCardInfo.birthday = idCardNoUtil.formateDateCN(aday);
            if (parseInt(idCardNo.charAt(14)) % 2 == 0) {
                idCardInfo.gender = idCardNoUtil.genders.female;
            } else {
                idCardInfo.gender = idCardNoUtil.genders.male;
            }
        } else if (idCardNo.length == 18) {
            var aday = idCardNo.substring(6, 14);
            idCardInfo.birthday = idCardNoUtil.formateDateCN(aday);
            if (parseInt(idCardNo.charAt(16)) % 2 == 0) {
                idCardInfo.gender = idCardNoUtil.genders.female;
            } else {
                idCardInfo.gender = idCardNoUtil.genders.male;
            }

        }
        return idCardInfo;
    },

    // 18位转15位
    getId15: function (idCardNo) {
        if (idCardNo.length == 15) {
            return idCardNo;
        } else if (idCardNo.length == 18) {
            return idCardNo.substring(0, 6) + idCardNo.substring(8, 17);
        } else {
            return null;
        }
    },

    // 15位转18位
    getId18: function (idCardNo) {
        if (idCardNo.length == 15) {
            var id17 = idCardNo.substring(0, 6) + '19' + idCardNo.substring(6);
            var parityBit = idCardNoUtil.getParityBit(id17);
            return id17 + parityBit;
        } else if (idCardNo.length == 18) {
            return idCardNo;
        } else {
            return null;
        }
    }
  };
  return {
    init: function () {
      layui.form.verify({
        moreT3Number: [
          /^[0-9]{0,3}$/,
          '不能超过3个字符'
        ],
        moreT8Number: [
          /^[0-9]{0,8}$/,
          '不能超过8个字符'
        ],
        moreT11Number: [
          /^[0-9]{0,11}$/,
          '不能超过11个字符'
        ],
        moreT12Number: [
          /^[0-9]{0,12}$/,
          '不能超过12个字符'
        ],
        hasT12Number: [
          /^[0-9]{12}$/,
          '仅支持输入12位数字'
        ],
        hasT12NumberLhh: [
          /^[0-9]{12}$/,
          '联行号仅支持输入12位数字'
        ],
        moreT122Number: [
          /^\d{1,12}(\.\d{1,2})?$/,
          '请输入12位以内的整数，小数最多支持2位'
        ],
        moreT162Number: [
          /^\d{1,16}(\.\d{1,2})?$/,
          '请输入16位以内的整数，小数最多支持2位'
        ],
        moreT16Number: [
          /^[0-9]{0,16}$/,
          '不能超过16个字符'
        ],
        moreT32Number: [
          /^.{0,32}$/,
          '不能超过32个字符'
        ],
        tradeYears: function (value) {
          if (parseFloat(value)<0||parseFloat(value)>999999.99) {
            return '交易年限输入:0<=交易年限<=999999.99'
          }
          return false;
        },
        FloatT2Number:function (value) {
          if (parseFloat(value)==0) {
            return false
          }
          if (!/^(([1-9][0-9]*)|(([0]\.\d{1,2}|[1-9][0-9]*\.\d{1,2})))$/.test(value)) {
            return '请保留2位小数'
          }
          return false;
        },
        checkUser: function (value) {//传真
          if (!/^(?!\d+$)[\da-zA-Z]+$/.test(value)) {
            return '登录账号只能输入3-15位英文字母、数字(不能是纯数字)。")'
          }
          return false;
        },
        loanBalance: function (value) {//传真
          var loanBalanceExist = layui.form.val('bank-form').loanBalanceExist
          if (loanBalanceExist === 'true') {
            if (!/^\d{1,12}(\.\d{1,2})?$/.test(value)) {
              return '12位以内的整数，小数最多2位'
            }
          }
          return false;
        },
        applicantFax: [//传真
          /^([0-9]{3,4})?[0-9]{7,8}$/,
          "请输入有效的电话号码:区号后面不能带有'-'"
        ],
        fixedTelephone: [//固定电话
          /^([0][0-9]*)$/,
          "必须以0开头,全部都是数字,不能有'-'"
        ],
        mobilePhone: [//移动电话
          /^1\d{10}$/,
          "请输入正确的手机号"
        ],
        contactNumber: function (value) {//传真
          var chkPhone = /^1\d{10}$/;
          var fixedTelephone = /^([0][0-9]*)$/;
          if (!((chkPhone.test(value)) || (fixedTelephone.test(value)))) {
            return '请输入有效的手机号码或固定号码'
          }
          return false;
        },
        bigNumber: [//只能是整数
          /^([1-9][0-9]*)$/,
          "只能是整数"
        ],

        // letter: [//字母
        //   /^[a-zA-Z]+$/,
        //   "只能是字母"
        // ],
        // number15: [
        //   /^[0-9]{0,15}$/,
        //   '不能超过15个字符'
        // ],
        
        financeRates: function (value, item) {//邮箱格式
          var wrapper = $(item).closest('.require');
          wrapper.removeClass("error").find(".error").remove()
          var reg =/^(\d{1,2}(\.[0-9]{1,6})?)$|^99$/
          if (!reg.test(value)) {
            wrapper.addClass('error').append('<span class="error">请输入小于100的合法数据,小数最多6位</span>')
              return true;
            }
            return false;
        },
        mail: function (value, item) {//邮箱格式
            var wrapper = $(item).closest('.require');
            wrapper.removeClass("error").find(".error").remove()
            var reg = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/
            if (!reg.test(value)) {
              wrapper.addClass('error').append('<span class="error">邮箱格式不正确</span>')
                return true;
            }
            return false;
        },
        phone: function (value, item) {//手机号
            var wrapper = $(item).closest('.require');
            wrapper.removeClass("error").find(".error").remove()
            var reg = /^1\d{10}$/
            if (!reg.test(value)) {
              wrapper.addClass('error').append('<span class="error">请输入正确的手机号</span>')
                return true;
            }
            return false;
        },
        number: function (value, item) {
          var wrapper = $(item).closest('.require');
          wrapper.removeClass("error").find(".error").remove()
          if (!value || isNaN(value)){
            wrapper.addClass('error').append('<span class="error">只能是数字</span>')
            return true
          }
          return false;
        },
        letter: function (value, item) {
          var wrapper = $(item).closest('.require');
          wrapper.removeClass("error").find(".error").remove()
          var reg = /^[a-zA-Z]+$/;
          var regExp = new RegExp(reg);
          if(!regExp.test(value)){
            wrapper.addClass('error').append('<span class="error">只能是字母</span>')
            return true
          }
          return false;
        },
        number15: function (value, item) {
          var wrapper = $(item).closest('.require');
          wrapper.removeClass("error").find(".error").remove()
          var reg = /^[0-9]{0,15}$/;
          var regExp = new RegExp(reg);
          if(!regExp.test(value)){
            wrapper.addClass('error').append('<span class="error">不能超过15个字符</span>')
            return true
          }
          return false;
        },
        date: function (value, item) {
          var wrapper = $(item).closest('.require');
          wrapper.removeClass("error").find(".error").remove()
          var reg = /^[1-9]\d{3}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])$/;
          var regExp = new RegExp(reg);
          if(!regExp.test(value)){
            wrapper.addClass('error').append('<span class="error">请输入正确的日期格式，例2022-01-01</span>')
            return true
          }
          return false;
        },
        bankNumber: function (value, item) {//联行号
            var wrapper = $(item).closest('.require');
            wrapper.removeClass("error").find(".error").remove()
            var reg = /^[0-9]{12}$/
            if (!reg.test(value)) {
              wrapper.addClass('error').append('<span class="error">联行号仅支持输入12位数字</span>')
                return true;
            }
            return false;
        },
        max8: function (value, item) {//操作员代码
            var wrapper = $(item).closest('.require');
            wrapper.removeClass("error").find(".error").remove()
            if (_.trim(value).length > 8) {
              wrapper.addClass('error').append('<span class="error">操作员代码不能超过8位</span>')
                return true;
            }
            return false;
        },
        maxlength: function (value, item) {
          var wrapper = $(item).closest('.require');
          wrapper.removeClass("error").find(".error").remove()
          var max = $(item).attr("lay-max");
          if (value.length > max) {
            wrapper.addClass('error').append(
              '<span class="error">请填写最多' + max + "位字符</span>"
            );
            return "请填写最多" + max + "位字符";
          }
          return false;
        }
        ,account: function (value, item) {//账号验证方式
            var wrapper = $(item).closest('.require');
            wrapper.removeClass("error").find(".error").remove()
            var reg = /^(?!\d+$)[^\?\!\,\.]{3,15}?$/
            if (!reg.test(value)) {
              wrapper.addClass('error').append('<span class="error">账号必须是3~15位字母或字母数字组合</span>')
                return true;
            }
            return false;
        } 
        ,emailText: function (value, item) {//邮箱格式
            var wrapper = $(item).closest('.require');
            wrapper.removeClass("error").find(".error").remove()
            var reg = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/
            if (!reg.test(value)) {
              wrapper.addClass('error').append('<span class="error">邮箱格式不正确</span>')
                return true;
            }
            return false;
        }
        ,phoneText: function (value, item) {//手机号
            var wrapper = $(item).closest('.require');
            wrapper.removeClass("error").find(".error").remove()
            var reg = /^1\d{10}$/
            if (!reg.test(value)) {
              wrapper.addClass('error').append('<span class="error">请输入正确的手机号</span>')
                return true;
            }
            return false;
        },
        isNumber:function (value, item) {//数字判断
          var wrapper = $(item).closest('.require');
          wrapper.removeClass("error").find(".error").remove()
          var reg = /^\d+(\.\d+)?$/;
          var regExp = new RegExp(reg);
          if(!regExp.test(value)){
            wrapper.addClass('error').append('<span class="error">只能是数字！</span>')
            return true
          }
          return false;
        },
        isNumber12:function (value, item) {//12位数字判断
          var wrapper = $(item).closest('.require');
          wrapper.removeClass("error").find(".error").remove()
          // var reg = /^[0-9]{12}$/;
          var reg = /^\d+(\.\d+)?$/
          var regExp = new RegExp(reg);
          if(!regExp.test(value)){
            wrapper.addClass('error').append('<span class="error">仅支持输入12位数字！</span>')
            return true
          }
          return false;
        },
        require: function (value, item) {//必填项
          var wrapper = $(item).closest('.require');
          wrapper.removeClass("error").find(".error").remove()
          var test = /^.+$/
          if (!test.test(value)) {
            wrapper.addClass('error').append('<span class="error">必填项不能为空</span>')
            return true
          }
          return false;
        },
        noRequire: function (value, item) {//非必填项
          var wrapper = $(item).closest('.require');
          wrapper.removeClass("error").find(".error").remove()
          return false;
        },
        blank:function (value,item) {//不能出现空白
          var wrapper = $(item).closest('.require');
            wrapper.removeClass("error").find(".error").remove()
            var test =  /^[\S]{1,1000000}$/
            if(!test.test(value)){
              wrapper.addClass('error').append('<span class="error">不能出现空白或换行</span>')
              return true
            }
          return false;
        },
        invoiceCode:function (value,item) {//发票代码
          var wrapper = $(item).closest('.require');
            wrapper.removeClass("error").find(".error").remove()
            var test = /^(\d{10}|\d{12})$/
            if(!test.test(value)){
              wrapper.addClass('error').append('<span class="error">发票代码只能是10位或12位!</span>')
              return true
            }
          return false;
        },
        invoiceNumber:function (value,item) {//发票号码
          var wrapper = $(item).closest('.require');
            wrapper.removeClass("error").find(".error").remove()
            var test = /^(\d{8})$/
            if(!test.test(value)){
              wrapper.addClass('error').append('<span class="error">发票号码只能是8位!</span>')
              return true
            }
          return false;
        },
        invoiceNumber20:function (value,item) {//发票号码
          var wrapper = $(item).closest('.require');
            wrapper.removeClass("error").find(".error").remove()
            var test = /^(\d{20})$/
            if(!test.test(value)){
              wrapper.addClass('error').append('<span class="error">发票号码只能是20位!</span>')
              return true
            }
          return false;
        },
        invoiceAmount:function (value,item) {//发票金额,发票含税金额
          var wrapper = $(item).closest('.require');
            wrapper.removeClass("error").find(".error").remove()
            var test = /^[0-9]\d{0,11}(\.\d{1,2})?$|^(0\.\d{1,2})?$/
            if(!test.test(value)){
              wrapper.addClass('error').append('<span class="error">12位以内的整数，小数最多2位</span>')
              return true
            }
          return false;
        },
        invoiceAmountExclusiveTax: function(value,item) {//发票金额>发票含税金额
          var wrapper = $(item).closest('.require');
          wrapper.removeClass("error").find(".error").remove()
          var invoiceAmount = layui.form.val('invoice-edit-view').invoiceAmount
          if(parseFloat(value)>parseFloat(invoiceAmount)) {
            wrapper.addClass('error').append('<span class="error">发票不含税金额应小于等于发票金额！</span>')
              return true
          } 
          return false;
        },
        invoiceCheckCode: function(value,item) {//发票校验码
          var wrapper = $(item).closest('.require');
          wrapper.removeClass("error").find(".error").remove()
          var invoiceType = layui.form.val('invoice-edit-view').invoiceType
          if((invoiceType == 1||invoiceType==5) && value.length<1) {
            wrapper.addClass('error').append('<span class="error">发票校验码不能为空！</span>')
              return true
          } 
          return false;
        },
        remark: function (value,item) {//50字备注
          var o = value || ''
          var wrapper = $(item).closest('.require');
            wrapper.removeClass("error").find(".error").remove()
            if(o.length>50){
              wrapper.addClass('error').append('<span class="error">不能超过50个字符!</span>')
              return true
            }
          return false;
        },
        contractRemark:function (value,item) {//200字备注
          var o = value || ''
          var wrapper = $(item).closest('.require');
            wrapper.removeClass("error").find(".error").remove()
            if(o.length>200){
              wrapper.addClass('error').append('<span class="error">不能超过200个字符!</span>')
              return true
            }
          return false;
        },
        onehundredfifty:function (value,item) {//150字备注
          var o = value || ''
          var wrapper = $(item).closest('.require');
            wrapper.removeClass("error").find(".error").remove()
            if(o.length>150){
              wrapper.addClass('error').append('<span class="error">不能超过150个字符!</span>')
              return true
            }
          return false;
        },
        threehundred:function (value,item) {//300字备注
          var o = value || ''
          var wrapper = $(item).closest('.require');
            wrapper.removeClass("error").find(".error").remove()
            if(o.length>300){
              wrapper.addClass('error').append('<span class="error">不能超过300个字符!</span>')
              return true
            }
          return false;
        },
        enterName:function (value, item) {//企业名称
          var wrapper = $(item).closest('.require');
          wrapper.removeClass("error").find(".error").remove()
          var reg = /^[\w\u4E00-\u9FA5（）()-·、.]{2,50}$/
          if (!reg.test(value)) {
            wrapper.addClass('error').append('<span class="error">请输入正确企业名称</span>')
              return true;
          }
          return false;
        },
        socialCreditCode:function (value,item) {//统一社会信用代码
          var wrapper = $(item).closest('.require');
            wrapper.removeClass("error").find(".error").remove()
            var test = /^[A-Z0-9]{18}$/i
            if(!test.test(value)){
              wrapper.addClass('error').append('<span class="error">统一社会信用代码仅支持输入18位数字和大写字母</span>')
              return true
            }
          return false;
        },
        amount:function (value,item) {//金额 12位
          var wrapper = $(item).closest('.require');
            wrapper.removeClass("error").find(".error").remove()
            var test = /^[0-9]\d{0,11}(\.\d{1,2})?$|^(0\.\d{1,2})?$/
            if(!test.test(value)){
              wrapper.addClass('error').append('<span class="error">12位以内的整数，小数最多2位</span>')
              return true
            }
          return false;
        },
        financeamount:function (value,item) {//金额2位小数
          var wrapper = $(item).closest('.require');
            wrapper.removeClass("error").find(".error").remove()
            var test = /^[0-9]\d{0,11}(\.\d{1,2})?$|^(0\.\d{1,2})?$/
            if(!test.test(value)){
              wrapper.addClass('error').append('<span class="error">只能是数字，最多两位小数!</span>')
              return true
            }
          return false;
        },
        idCardNo:function (value,item) {//身份证
          var wrapper = $(item).closest('.require');
            wrapper.removeClass("error").find(".error").remove()
            if(!idCardNoUtil.checkIdCardNo(value)){
              wrapper.addClass('error').append('<span class="error">请输入有效的身份证件号!</span>')
              return true
            }
          return false;
        },
        identity: function (value, item) {//工作组身份证
          var wrapper = $(item).closest('.require');
          wrapper.removeClass("error").find(".error").remove()
          var reg = /(^\d{15}$)|(^\d{17}(x|X|\d)$)/;
          if ($("#identityType").val() === "1") {
            if (!reg.test(value)) {
              wrapper.addClass('error').append('<span class="error">请输入正确的身份证号</span>');
              return true
            }
            return false;
          }
          return false;
        },
        enterpriseName:function (value,item) {//企业简称
          var wrapper = $(item).closest('.require');
            wrapper.removeClass("error").find(".error").remove()
            var test = /^[^\s]{1,45}$/
            if(!test.test(value)){
              wrapper.addClass('error').append('<span class="error">支持1-45字符的企业简称!</span>')
              return true
            }
          return false;
        },
        
        big100:function (value,item) {//最小100
          var wrapper = $(item).closest('.require');
            wrapper.removeClass("error").find(".error").remove()
            
            if(parseFloat(value)<100){
              wrapper.addClass('error').append('<span class="error">最小100!</span>')
              return true
            }
          return false;
        },
        // 订单贷自己需求额度
        capitalRequirementAmount:function (value) {//传真
          
          var test = /^\d{1,12}(\.\d{1,4})?$/;
          if(value.length<1){
            return false
          }else if (!test.test(value)) {
            return '请输入12位以内的整数，小数最多支持4位'
          }else{
            return false;
          }
          
        },
        isNum:function (value,item) {//只能是数字
          var wrapper = $(item).closest('.require');
            wrapper.removeClass("error").find(".error").remove()
            var test = /^[0-9]+.?[0-9]*/
            if(!test.test(value)){
              wrapper.addClass('error').append('<span class="error">只能是数字!</span>')
              return true
            }
          return false;
        },
        passwordNew:function (value,item) {//只能是数字
          var wrapper = $(item).closest('.require');
            wrapper.removeClass("error").find(".error").remove()
            var test = /^(?!.*\s)(?=.*[A-Z])(?=.*[a-z])(?=.*[0-9])(?=.*[\W_]).{8,16}$/
            if(!test.test(value)){
              wrapper.addClass('error').append('<span class="error">密码必须是8-16位，需同时包含大写字母、小写字母、数字、特殊字符4种!</span>')
              return true
            }
          return false;
        },
        passwordNewLx:function (value,item) {//只能是数字
          var wrapper = $(item).closest('.require');
            wrapper.removeClass("error").find(".error").remove()
            var test = /^(?=.*[a-z])(?=.*[A-Z])(?=.*[A-Z])(?=.*\d)(?=.*[!.@#$%^&*()\-+])(?!.*(.)\1{2})(?!.*(?:012|123|234|345|456|567|678|789))[a-zA-Z0-9!.@#$%^&*()\-+]{8,}$/
            if(!test.test(value)){
              wrapper.addClass('error').append('<span class="error">密码中不能包含3个及以上连续的数字或连续相同的字符!</span>')
              return true
            }
          return false;
        },
        pswAnDnewPsw:function (value,item) {//只能是数字
          var wrapper = $(item).closest('.require');
            wrapper.removeClass("error").find(".error").remove()
            
            if(value!==$("#newPsw").val()){
              wrapper.addClass('error').append('<span class="error">密码不一致，请重新输入!</span>')
              return true
            }
          return false;
        }
       
            
            
        })
      }
    }

  }();
// LayuiFormValidation.init();
/**
 * @license
 * lodash 3.10.1 (Custom Build) lodash.com/license | Underscore.js 1.8.3 underscorejs.org/LICENSE
 * Build: `lodash modern -o ./lodash.js`
 */
;(function(){function n(n,t){if(n!==t){var r=null===n,e=n===w,u=n===n,o=null===t,i=t===w,f=t===t;if(n>t&&!o||!u||r&&!i&&f||e&&f)return 1;if(n<t&&!r||!f||o&&!e&&u||i&&u)return-1}return 0}function t(n,t,r){for(var e=n.length,u=r?e:-1;r?u--:++u<e;)if(t(n[u],u,n))return u;return-1}function r(n,t,r){if(t!==t)return p(n,r);r-=1;for(var e=n.length;++r<e;)if(n[r]===t)return r;return-1}function e(n){return typeof n=="function"||false}function u(n){return null==n?"":n+""}function o(n,t){for(var r=-1,e=n.length;++r<e&&-1<t.indexOf(n.charAt(r)););
return r}function i(n,t){for(var r=n.length;r--&&-1<t.indexOf(n.charAt(r)););return r}function f(t,r){return n(t.a,r.a)||t.b-r.b}function a(n){return Nn[n]}function c(n){return Tn[n]}function l(n,t,r){return t?n=Bn[n]:r&&(n=Dn[n]),"\\"+n}function s(n){return"\\"+Dn[n]}function p(n,t,r){var e=n.length;for(t+=r?0:-1;r?t--:++t<e;){var u=n[t];if(u!==u)return t}return-1}function h(n){return!!n&&typeof n=="object"}function _(n){return 160>=n&&9<=n&&13>=n||32==n||160==n||5760==n||6158==n||8192<=n&&(8202>=n||8232==n||8233==n||8239==n||8287==n||12288==n||65279==n);
}function v(n,t){for(var r=-1,e=n.length,u=-1,o=[];++r<e;)n[r]===t&&(n[r]=z,o[++u]=r);return o}function g(n){for(var t=-1,r=n.length;++t<r&&_(n.charCodeAt(t)););return t}function y(n){for(var t=n.length;t--&&_(n.charCodeAt(t)););return t}function d(n){return Ln[n]}function m(_){function Nn(n){if(h(n)&&!(Oo(n)||n instanceof zn)){if(n instanceof Ln)return n;if(nu.call(n,"__chain__")&&nu.call(n,"__wrapped__"))return Mr(n)}return new Ln(n)}function Tn(){}function Ln(n,t,r){this.__wrapped__=n,this.__actions__=r||[],
this.__chain__=!!t}function zn(n){this.__wrapped__=n,this.__actions__=[],this.__dir__=1,this.__filtered__=false,this.__iteratees__=[],this.__takeCount__=Ru,this.__views__=[]}function Bn(){this.__data__={}}function Dn(n){var t=n?n.length:0;for(this.data={hash:gu(null),set:new lu};t--;)this.push(n[t])}function Mn(n,t){var r=n.data;return(typeof t=="string"||ge(t)?r.set.has(t):r.hash[t])?0:-1}function qn(n,t){var r=-1,e=n.length;for(t||(t=Be(e));++r<e;)t[r]=n[r];return t}function Pn(n,t){for(var r=-1,e=n.length;++r<e&&false!==t(n[r],r,n););
return n}function Kn(n,t){for(var r=-1,e=n.length;++r<e;)if(!t(n[r],r,n))return false;return true}function Vn(n,t){for(var r=-1,e=n.length,u=-1,o=[];++r<e;){var i=n[r];t(i,r,n)&&(o[++u]=i)}return o}function Gn(n,t){for(var r=-1,e=n.length,u=Be(e);++r<e;)u[r]=t(n[r],r,n);return u}function Jn(n,t){for(var r=-1,e=t.length,u=n.length;++r<e;)n[u+r]=t[r];return n}function Xn(n,t,r,e){var u=-1,o=n.length;for(e&&o&&(r=n[++u]);++u<o;)r=t(r,n[u],u,n);return r}function Hn(n,t){for(var r=-1,e=n.length;++r<e;)if(t(n[r],r,n))return true;
return false}function Qn(n,t,r,e){return n!==w&&nu.call(e,r)?n:t}function nt(n,t,r){for(var e=-1,u=zo(t),o=u.length;++e<o;){var i=u[e],f=n[i],a=r(f,t[i],i,n,t);(a===a?a===f:f!==f)&&(f!==w||i in n)||(n[i]=a)}return n}function tt(n,t){return null==t?n:et(t,zo(t),n)}function rt(n,t){for(var r=-1,e=null==n,u=!e&&Er(n),o=u?n.length:0,i=t.length,f=Be(i);++r<i;){var a=t[r];f[r]=u?Cr(a,o)?n[a]:w:e?w:n[a]}return f}function et(n,t,r){r||(r={});for(var e=-1,u=t.length;++e<u;){var o=t[e];r[o]=n[o]}return r}function ut(n,t,r){
var e=typeof n;return"function"==e?t===w?n:Bt(n,t,r):null==n?Fe:"object"==e?bt(n):t===w?ze(n):xt(n,t)}function ot(n,t,r,e,u,o,i){var f;if(r&&(f=u?r(n,e,u):r(n)),f!==w)return f;if(!ge(n))return n;if(e=Oo(n)){if(f=kr(n),!t)return qn(n,f)}else{var a=ru.call(n),c=a==K;if(a!=Z&&a!=B&&(!c||u))return Fn[a]?Rr(n,a,t):u?n:{};if(f=Ir(c?{}:n),!t)return tt(f,n)}for(o||(o=[]),i||(i=[]),u=o.length;u--;)if(o[u]==n)return i[u];return o.push(n),i.push(f),(e?Pn:_t)(n,function(e,u){f[u]=ot(e,t,r,u,n,o,i)}),f}function it(n,t,r){
if(typeof n!="function")throw new Ge(L);return su(function(){n.apply(w,r)},t)}function ft(n,t){var e=n?n.length:0,u=[];if(!e)return u;var o=-1,i=xr(),f=i===r,a=f&&t.length>=F&&gu&&lu?new Dn(t):null,c=t.length;a&&(i=Mn,f=false,t=a);n:for(;++o<e;)if(a=n[o],f&&a===a){for(var l=c;l--;)if(t[l]===a)continue n;u.push(a)}else 0>i(t,a,0)&&u.push(a);return u}function at(n,t){var r=true;return Su(n,function(n,e,u){return r=!!t(n,e,u)}),r}function ct(n,t,r,e){var u=e,o=u;return Su(n,function(n,i,f){i=+t(n,i,f),(r(i,u)||i===e&&i===o)&&(u=i,
o=n)}),o}function lt(n,t){var r=[];return Su(n,function(n,e,u){t(n,e,u)&&r.push(n)}),r}function st(n,t,r,e){var u;return r(n,function(n,r,o){return t(n,r,o)?(u=e?r:n,false):void 0}),u}function pt(n,t,r,e){e||(e=[]);for(var u=-1,o=n.length;++u<o;){var i=n[u];h(i)&&Er(i)&&(r||Oo(i)||pe(i))?t?pt(i,t,r,e):Jn(e,i):r||(e[e.length]=i)}return e}function ht(n,t){Nu(n,t,Re)}function _t(n,t){return Nu(n,t,zo)}function vt(n,t){return Tu(n,t,zo)}function gt(n,t){for(var r=-1,e=t.length,u=-1,o=[];++r<e;){var i=t[r];
ve(n[i])&&(o[++u]=i)}return o}function yt(n,t,r){if(null!=n){r!==w&&r in Br(n)&&(t=[r]),r=0;for(var e=t.length;null!=n&&r<e;)n=n[t[r++]];return r&&r==e?n:w}}function dt(n,t,r,e,u,o){if(n===t)n=true;else if(null==n||null==t||!ge(n)&&!h(t))n=n!==n&&t!==t;else n:{var i=dt,f=Oo(n),a=Oo(t),c=D,l=D;f||(c=ru.call(n),c==B?c=Z:c!=Z&&(f=xe(n))),a||(l=ru.call(t),l==B?l=Z:l!=Z&&xe(t));var s=c==Z,a=l==Z,l=c==l;if(!l||f||s){if(!e&&(c=s&&nu.call(n,"__wrapped__"),a=a&&nu.call(t,"__wrapped__"),c||a)){n=i(c?n.value():n,a?t.value():t,r,e,u,o);
break n}if(l){for(u||(u=[]),o||(o=[]),c=u.length;c--;)if(u[c]==n){n=o[c]==t;break n}u.push(n),o.push(t),n=(f?yr:mr)(n,t,i,r,e,u,o),u.pop(),o.pop()}else n=false}else n=dr(n,t,c)}return n}function mt(n,t,r){var e=t.length,u=e,o=!r;if(null==n)return!u;for(n=Br(n);e--;){var i=t[e];if(o&&i[2]?i[1]!==n[i[0]]:!(i[0]in n))return false}for(;++e<u;){var i=t[e],f=i[0],a=n[f],c=i[1];if(o&&i[2]){if(a===w&&!(f in n))return false}else if(i=r?r(a,c,f):w,i===w?!dt(c,a,r,true):!i)return false}return true}function wt(n,t){var r=-1,e=Er(n)?Be(n.length):[];
return Su(n,function(n,u,o){e[++r]=t(n,u,o)}),e}function bt(n){var t=Ar(n);if(1==t.length&&t[0][2]){var r=t[0][0],e=t[0][1];return function(n){return null==n?false:n[r]===e&&(e!==w||r in Br(n))}}return function(n){return mt(n,t)}}function xt(n,t){var r=Oo(n),e=Wr(n)&&t===t&&!ge(t),u=n+"";return n=Dr(n),function(o){if(null==o)return false;var i=u;if(o=Br(o),!(!r&&e||i in o)){if(o=1==n.length?o:yt(o,Et(n,0,-1)),null==o)return false;i=Zr(n),o=Br(o)}return o[i]===t?t!==w||i in o:dt(t,o[i],w,true)}}function At(n,t,r,e,u){
if(!ge(n))return n;var o=Er(t)&&(Oo(t)||xe(t)),i=o?w:zo(t);return Pn(i||t,function(f,a){if(i&&(a=f,f=t[a]),h(f)){e||(e=[]),u||(u=[]);n:{for(var c=a,l=e,s=u,p=l.length,_=t[c];p--;)if(l[p]==_){n[c]=s[p];break n}var p=n[c],v=r?r(p,_,c,n,t):w,g=v===w;g&&(v=_,Er(_)&&(Oo(_)||xe(_))?v=Oo(p)?p:Er(p)?qn(p):[]:me(_)||pe(_)?v=pe(p)?ke(p):me(p)?p:{}:g=false),l.push(_),s.push(v),g?n[c]=At(v,_,r,l,s):(v===v?v!==p:p===p)&&(n[c]=v)}}else c=n[a],l=r?r(c,f,a,n,t):w,(s=l===w)&&(l=f),l===w&&(!o||a in n)||!s&&(l===l?l===c:c!==c)||(n[a]=l);
}),n}function jt(n){return function(t){return null==t?w:t[n]}}function kt(n){var t=n+"";return n=Dr(n),function(r){return yt(r,n,t)}}function It(n,t){for(var r=n?t.length:0;r--;){var e=t[r];if(e!=u&&Cr(e)){var u=e;pu.call(n,e,1)}}}function Rt(n,t){return n+yu(ku()*(t-n+1))}function Ot(n,t,r,e,u){return u(n,function(n,u,o){r=e?(e=false,n):t(r,n,u,o)}),r}function Et(n,t,r){var e=-1,u=n.length;for(t=null==t?0:+t||0,0>t&&(t=-t>u?0:u+t),r=r===w||r>u?u:+r||0,0>r&&(r+=u),u=t>r?0:r-t>>>0,t>>>=0,r=Be(u);++e<u;)r[e]=n[e+t];
return r}function Ct(n,t){var r;return Su(n,function(n,e,u){return r=t(n,e,u),!r}),!!r}function Ut(n,t){var r=n.length;for(n.sort(t);r--;)n[r]=n[r].c;return n}function Wt(t,r,e){var u=wr(),o=-1;return r=Gn(r,function(n){return u(n)}),t=wt(t,function(n){return{a:Gn(r,function(t){return t(n)}),b:++o,c:n}}),Ut(t,function(t,r){var u;n:{for(var o=-1,i=t.a,f=r.a,a=i.length,c=e.length;++o<a;)if(u=n(i[o],f[o])){if(o>=c)break n;o=e[o],u*="asc"===o||true===o?1:-1;break n}u=t.b-r.b}return u})}function $t(n,t){
var r=0;return Su(n,function(n,e,u){r+=+t(n,e,u)||0}),r}function St(n,t){var e=-1,u=xr(),o=n.length,i=u===r,f=i&&o>=F,a=f&&gu&&lu?new Dn(void 0):null,c=[];a?(u=Mn,i=false):(f=false,a=t?[]:c);n:for(;++e<o;){var l=n[e],s=t?t(l,e,n):l;if(i&&l===l){for(var p=a.length;p--;)if(a[p]===s)continue n;t&&a.push(s),c.push(l)}else 0>u(a,s,0)&&((t||f)&&a.push(s),c.push(l))}return c}function Ft(n,t){for(var r=-1,e=t.length,u=Be(e);++r<e;)u[r]=n[t[r]];return u}function Nt(n,t,r,e){for(var u=n.length,o=e?u:-1;(e?o--:++o<u)&&t(n[o],o,n););
return r?Et(n,e?0:o,e?o+1:u):Et(n,e?o+1:0,e?u:o)}function Tt(n,t){var r=n;r instanceof zn&&(r=r.value());for(var e=-1,u=t.length;++e<u;)var o=t[e],r=o.func.apply(o.thisArg,Jn([r],o.args));return r}function Lt(n,t,r){var e=0,u=n?n.length:e;if(typeof t=="number"&&t===t&&u<=Eu){for(;e<u;){var o=e+u>>>1,i=n[o];(r?i<=t:i<t)&&null!==i?e=o+1:u=o}return u}return zt(n,t,Fe,r)}function zt(n,t,r,e){t=r(t);for(var u=0,o=n?n.length:0,i=t!==t,f=null===t,a=t===w;u<o;){var c=yu((u+o)/2),l=r(n[c]),s=l!==w,p=l===l;
(i?p||e:f?p&&s&&(e||null!=l):a?p&&(e||s):null==l?0:e?l<=t:l<t)?u=c+1:o=c}return xu(o,Ou)}function Bt(n,t,r){if(typeof n!="function")return Fe;if(t===w)return n;switch(r){case 1:return function(r){return n.call(t,r)};case 3:return function(r,e,u){return n.call(t,r,e,u)};case 4:return function(r,e,u,o){return n.call(t,r,e,u,o)};case 5:return function(r,e,u,o,i){return n.call(t,r,e,u,o,i)}}return function(){return n.apply(t,arguments)}}function Dt(n){var t=new ou(n.byteLength);return new hu(t).set(new hu(n)),
t}function Mt(n,t,r){for(var e=r.length,u=-1,o=bu(n.length-e,0),i=-1,f=t.length,a=Be(f+o);++i<f;)a[i]=t[i];for(;++u<e;)a[r[u]]=n[u];for(;o--;)a[i++]=n[u++];return a}function qt(n,t,r){for(var e=-1,u=r.length,o=-1,i=bu(n.length-u,0),f=-1,a=t.length,c=Be(i+a);++o<i;)c[o]=n[o];for(i=o;++f<a;)c[i+f]=t[f];for(;++e<u;)c[i+r[e]]=n[o++];return c}function Pt(n,t){return function(r,e,u){var o=t?t():{};if(e=wr(e,u,3),Oo(r)){u=-1;for(var i=r.length;++u<i;){var f=r[u];n(o,f,e(f,u,r),r)}}else Su(r,function(t,r,u){
n(o,t,e(t,r,u),u)});return o}}function Kt(n){return le(function(t,r){var e=-1,u=null==t?0:r.length,o=2<u?r[u-2]:w,i=2<u?r[2]:w,f=1<u?r[u-1]:w;for(typeof o=="function"?(o=Bt(o,f,5),u-=2):(o=typeof f=="function"?f:w,u-=o?1:0),i&&Ur(r[0],r[1],i)&&(o=3>u?w:o,u=1);++e<u;)(i=r[e])&&n(t,i,o);return t})}function Vt(n,t){return function(r,e){var u=r?Bu(r):0;if(!Sr(u))return n(r,e);for(var o=t?u:-1,i=Br(r);(t?o--:++o<u)&&false!==e(i[o],o,i););return r}}function Zt(n){return function(t,r,e){var u=Br(t);e=e(t);for(var o=e.length,i=n?o:-1;n?i--:++i<o;){
var f=e[i];if(false===r(u[f],f,u))break}return t}}function Yt(n,t){function r(){return(this&&this!==Zn&&this instanceof r?e:n).apply(t,arguments)}var e=Jt(n);return r}function Gt(n){return function(t){var r=-1;t=$e(Ce(t));for(var e=t.length,u="";++r<e;)u=n(u,t[r],r);return u}}function Jt(n){return function(){var t=arguments;switch(t.length){case 0:return new n;case 1:return new n(t[0]);case 2:return new n(t[0],t[1]);case 3:return new n(t[0],t[1],t[2]);case 4:return new n(t[0],t[1],t[2],t[3]);case 5:
return new n(t[0],t[1],t[2],t[3],t[4]);case 6:return new n(t[0],t[1],t[2],t[3],t[4],t[5]);case 7:return new n(t[0],t[1],t[2],t[3],t[4],t[5],t[6])}var r=$u(n.prototype),t=n.apply(r,t);return ge(t)?t:r}}function Xt(n){function t(r,e,u){return u&&Ur(r,e,u)&&(e=w),r=gr(r,n,w,w,w,w,w,e),r.placeholder=t.placeholder,r}return t}function Ht(n,t){return le(function(r){var e=r[0];return null==e?e:(r.push(t),n.apply(w,r))})}function Qt(n,t){return function(r,e,u){if(u&&Ur(r,e,u)&&(e=w),e=wr(e,u,3),1==e.length){
u=r=Oo(r)?r:zr(r);for(var o=e,i=-1,f=u.length,a=t,c=a;++i<f;){var l=u[i],s=+o(l);n(s,a)&&(a=s,c=l)}if(u=c,!r.length||u!==t)return u}return ct(r,e,n,t)}}function nr(n,r){return function(e,u,o){return u=wr(u,o,3),Oo(e)?(u=t(e,u,r),-1<u?e[u]:w):st(e,u,n)}}function tr(n){return function(r,e,u){return r&&r.length?(e=wr(e,u,3),t(r,e,n)):-1}}function rr(n){return function(t,r,e){return r=wr(r,e,3),st(t,r,n,true)}}function er(n){return function(){for(var t,r=arguments.length,e=n?r:-1,u=0,o=Be(r);n?e--:++e<r;){
var i=o[u++]=arguments[e];if(typeof i!="function")throw new Ge(L);!t&&Ln.prototype.thru&&"wrapper"==br(i)&&(t=new Ln([],true))}for(e=t?-1:r;++e<r;){var i=o[e],u=br(i),f="wrapper"==u?zu(i):w;t=f&&$r(f[0])&&f[1]==(E|k|R|C)&&!f[4].length&&1==f[9]?t[br(f[0])].apply(t,f[3]):1==i.length&&$r(i)?t[u]():t.thru(i)}return function(){var n=arguments,e=n[0];if(t&&1==n.length&&Oo(e)&&e.length>=F)return t.plant(e).value();for(var u=0,n=r?o[u].apply(this,n):e;++u<r;)n=o[u].call(this,n);return n}}}function ur(n,t){
return function(r,e,u){return typeof e=="function"&&u===w&&Oo(r)?n(r,e):t(r,Bt(e,u,3))}}function or(n){return function(t,r,e){return(typeof r!="function"||e!==w)&&(r=Bt(r,e,3)),n(t,r,Re)}}function ir(n){return function(t,r,e){return(typeof r!="function"||e!==w)&&(r=Bt(r,e,3)),n(t,r)}}function fr(n){return function(t,r,e){var u={};return r=wr(r,e,3),_t(t,function(t,e,o){o=r(t,e,o),e=n?o:e,t=n?t:o,u[e]=t}),u}}function ar(n){return function(t,r,e){return t=u(t),(n?t:"")+pr(t,r,e)+(n?"":t)}}function cr(n){
var t=le(function(r,e){var u=v(e,t.placeholder);return gr(r,n,w,e,u)});return t}function lr(n,t){return function(r,e,u,o){var i=3>arguments.length;return typeof e=="function"&&o===w&&Oo(r)?n(r,e,u,i):Ot(r,wr(e,o,4),u,i,t)}}function sr(n,t,r,e,u,o,i,f,a,c){function l(){for(var m=arguments.length,b=m,j=Be(m);b--;)j[b]=arguments[b];if(e&&(j=Mt(j,e,u)),o&&(j=qt(j,o,i)),_||y){var b=l.placeholder,k=v(j,b),m=m-k.length;if(m<c){var I=f?qn(f):w,m=bu(c-m,0),E=_?k:w,k=_?w:k,C=_?j:w,j=_?w:j;return t|=_?R:O,t&=~(_?O:R),
g||(t&=~(x|A)),j=[n,t,r,C,E,j,k,I,a,m],I=sr.apply(w,j),$r(n)&&Du(I,j),I.placeholder=b,I}}if(b=p?r:this,I=h?b[n]:n,f)for(m=j.length,E=xu(f.length,m),k=qn(j);E--;)C=f[E],j[E]=Cr(C,m)?k[C]:w;return s&&a<j.length&&(j.length=a),this&&this!==Zn&&this instanceof l&&(I=d||Jt(n)),I.apply(b,j)}var s=t&E,p=t&x,h=t&A,_=t&k,g=t&j,y=t&I,d=h?w:Jt(n);return l}function pr(n,t,r){return n=n.length,t=+t,n<t&&mu(t)?(t-=n,r=null==r?" ":r+"",Ue(r,vu(t/r.length)).slice(0,t)):""}function hr(n,t,r,e){function u(){for(var t=-1,f=arguments.length,a=-1,c=e.length,l=Be(c+f);++a<c;)l[a]=e[a];
for(;f--;)l[a++]=arguments[++t];return(this&&this!==Zn&&this instanceof u?i:n).apply(o?r:this,l)}var o=t&x,i=Jt(n);return u}function _r(n){var t=Pe[n];return function(n,r){return(r=r===w?0:+r||0)?(r=au(10,r),t(n*r)/r):t(n)}}function vr(n){return function(t,r,e,u){var o=wr(e);return null==e&&o===ut?Lt(t,r,n):zt(t,r,o(e,u,1),n)}}function gr(n,t,r,e,u,o,i,f){var a=t&A;if(!a&&typeof n!="function")throw new Ge(L);var c=e?e.length:0;if(c||(t&=~(R|O),e=u=w),c-=u?u.length:0,t&O){var l=e,s=u;e=u=w}var p=a?w:zu(n);
return r=[n,t,r,e,u,l,s,o,i,f],p&&(e=r[1],t=p[1],f=e|t,u=t==E&&e==k||t==E&&e==C&&r[7].length<=p[8]||t==(E|C)&&e==k,(f<E||u)&&(t&x&&(r[2]=p[2],f|=e&x?0:j),(e=p[3])&&(u=r[3],r[3]=u?Mt(u,e,p[4]):qn(e),r[4]=u?v(r[3],z):qn(p[4])),(e=p[5])&&(u=r[5],r[5]=u?qt(u,e,p[6]):qn(e),r[6]=u?v(r[5],z):qn(p[6])),(e=p[7])&&(r[7]=qn(e)),t&E&&(r[8]=null==r[8]?p[8]:xu(r[8],p[8])),null==r[9]&&(r[9]=p[9]),r[0]=p[0],r[1]=f),t=r[1],f=r[9]),r[9]=null==f?a?0:n.length:bu(f-c,0)||0,(p?Lu:Du)(t==x?Yt(r[0],r[2]):t!=R&&t!=(x|R)||r[4].length?sr.apply(w,r):hr.apply(w,r),r);
}function yr(n,t,r,e,u,o,i){var f=-1,a=n.length,c=t.length;if(a!=c&&(!u||c<=a))return false;for(;++f<a;){var l=n[f],c=t[f],s=e?e(u?c:l,u?l:c,f):w;if(s!==w){if(s)continue;return false}if(u){if(!Hn(t,function(n){return l===n||r(l,n,e,u,o,i)}))return false}else if(l!==c&&!r(l,c,e,u,o,i))return false}return true}function dr(n,t,r){switch(r){case M:case q:return+n==+t;case P:return n.name==t.name&&n.message==t.message;case V:return n!=+n?t!=+t:n==+t;case Y:case G:return n==t+""}return false}function mr(n,t,r,e,u,o,i){var f=zo(n),a=f.length,c=zo(t).length;
if(a!=c&&!u)return false;for(c=a;c--;){var l=f[c];if(!(u?l in t:nu.call(t,l)))return false}for(var s=u;++c<a;){var l=f[c],p=n[l],h=t[l],_=e?e(u?h:p,u?p:h,l):w;if(_===w?!r(p,h,e,u,o,i):!_)return false;s||(s="constructor"==l)}return s||(r=n.constructor,e=t.constructor,!(r!=e&&"constructor"in n&&"constructor"in t)||typeof r=="function"&&r instanceof r&&typeof e=="function"&&e instanceof e)?true:false}function wr(n,t,r){var e=Nn.callback||Se,e=e===Se?ut:e;return r?e(n,t,r):e}function br(n){for(var t=n.name+"",r=Wu[t],e=r?r.length:0;e--;){
var u=r[e],o=u.func;if(null==o||o==n)return u.name}return t}function xr(n,t,e){var u=Nn.indexOf||Vr,u=u===Vr?r:u;return n?u(n,t,e):u}function Ar(n){n=Oe(n);for(var t=n.length;t--;){var r=n[t][1];n[t][2]=r===r&&!ge(r)}return n}function jr(n,t){var r=null==n?w:n[t];return ye(r)?r:w}function kr(n){var t=n.length,r=new n.constructor(t);return t&&"string"==typeof n[0]&&nu.call(n,"index")&&(r.index=n.index,r.input=n.input),r}function Ir(n){return n=n.constructor,typeof n=="function"&&n instanceof n||(n=Ve),
new n}function Rr(n,t,r){var e=n.constructor;switch(t){case J:return Dt(n);case M:case q:return new e(+n);case X:case H:case Q:case nn:case tn:case rn:case en:case un:case on:return t=n.buffer,new e(r?Dt(t):t,n.byteOffset,n.length);case V:case G:return new e(n);case Y:var u=new e(n.source,kn.exec(n));u.lastIndex=n.lastIndex}return u}function Or(n,t,r){return null==n||Wr(t,n)||(t=Dr(t),n=1==t.length?n:yt(n,Et(t,0,-1)),t=Zr(t)),t=null==n?n:n[t],null==t?w:t.apply(n,r)}function Er(n){return null!=n&&Sr(Bu(n));
}function Cr(n,t){return n=typeof n=="number"||On.test(n)?+n:-1,t=null==t?Cu:t,-1<n&&0==n%1&&n<t}function Ur(n,t,r){if(!ge(r))return false;var e=typeof t;return("number"==e?Er(r)&&Cr(t,r.length):"string"==e&&t in r)?(t=r[t],n===n?n===t:t!==t):false}function Wr(n,t){var r=typeof n;return"string"==r&&dn.test(n)||"number"==r?true:Oo(n)?false:!yn.test(n)||null!=t&&n in Br(t)}function $r(n){var t=br(n),r=Nn[t];return typeof r=="function"&&t in zn.prototype?n===r?true:(t=zu(r),!!t&&n===t[0]):false}function Sr(n){return typeof n=="number"&&-1<n&&0==n%1&&n<=Cu;
}function Fr(n,t){return n===w?t:Eo(n,t,Fr)}function Nr(n,t){n=Br(n);for(var r=-1,e=t.length,u={};++r<e;){var o=t[r];o in n&&(u[o]=n[o])}return u}function Tr(n,t){var r={};return ht(n,function(n,e,u){t(n,e,u)&&(r[e]=n)}),r}function Lr(n){for(var t=Re(n),r=t.length,e=r&&n.length,u=!!e&&Sr(e)&&(Oo(n)||pe(n)),o=-1,i=[];++o<r;){var f=t[o];(u&&Cr(f,e)||nu.call(n,f))&&i.push(f)}return i}function zr(n){return null==n?[]:Er(n)?ge(n)?n:Ve(n):Ee(n)}function Br(n){return ge(n)?n:Ve(n)}function Dr(n){if(Oo(n))return n;
var t=[];return u(n).replace(mn,function(n,r,e,u){t.push(e?u.replace(An,"$1"):r||n)}),t}function Mr(n){return n instanceof zn?n.clone():new Ln(n.__wrapped__,n.__chain__,qn(n.__actions__))}function qr(n,t,r){return n&&n.length?((r?Ur(n,t,r):null==t)&&(t=1),Et(n,0>t?0:t)):[]}function Pr(n,t,r){var e=n?n.length:0;return e?((r?Ur(n,t,r):null==t)&&(t=1),t=e-(+t||0),Et(n,0,0>t?0:t)):[]}function Kr(n){return n?n[0]:w}function Vr(n,t,e){var u=n?n.length:0;if(!u)return-1;if(typeof e=="number")e=0>e?bu(u+e,0):e;else if(e)return e=Lt(n,t),
e<u&&(t===t?t===n[e]:n[e]!==n[e])?e:-1;return r(n,t,e||0)}function Zr(n){var t=n?n.length:0;return t?n[t-1]:w}function Yr(n){return qr(n,1)}function Gr(n,t,e,u){if(!n||!n.length)return[];null!=t&&typeof t!="boolean"&&(u=e,e=Ur(n,t,u)?w:t,t=false);var o=wr();if((null!=e||o!==ut)&&(e=o(e,u,3)),t&&xr()===r){t=e;var i;e=-1,u=n.length;for(var o=-1,f=[];++e<u;){var a=n[e],c=t?t(a,e,n):a;e&&i===c||(i=c,f[++o]=a)}n=f}else n=St(n,e);return n}function Jr(n){if(!n||!n.length)return[];var t=-1,r=0;n=Vn(n,function(n){
return Er(n)?(r=bu(n.length,r),true):void 0});for(var e=Be(r);++t<r;)e[t]=Gn(n,jt(t));return e}function Xr(n,t,r){return n&&n.length?(n=Jr(n),null==t?n:(t=Bt(t,r,4),Gn(n,function(n){return Xn(n,t,w,true)}))):[]}function Hr(n,t){var r=-1,e=n?n.length:0,u={};for(!e||t||Oo(n[0])||(t=[]);++r<e;){var o=n[r];t?u[o]=t[r]:o&&(u[o[0]]=o[1])}return u}function Qr(n){return n=Nn(n),n.__chain__=true,n}function ne(n,t,r){return t.call(r,n)}function te(n,t,r){var e=Oo(n)?Kn:at;return r&&Ur(n,t,r)&&(t=w),(typeof t!="function"||r!==w)&&(t=wr(t,r,3)),
e(n,t)}function re(n,t,r){var e=Oo(n)?Vn:lt;return t=wr(t,r,3),e(n,t)}function ee(n,t,r,e){var u=n?Bu(n):0;return Sr(u)||(n=Ee(n),u=n.length),r=typeof r!="number"||e&&Ur(t,r,e)?0:0>r?bu(u+r,0):r||0,typeof n=="string"||!Oo(n)&&be(n)?r<=u&&-1<n.indexOf(t,r):!!u&&-1<xr(n,t,r)}function ue(n,t,r){var e=Oo(n)?Gn:wt;return t=wr(t,r,3),e(n,t)}function oe(n,t,r){if(r?Ur(n,t,r):null==t){n=zr(n);var e=n.length;return 0<e?n[Rt(0,e-1)]:w}r=-1,n=je(n);var e=n.length,u=e-1;for(t=xu(0>t?0:+t||0,e);++r<t;){var e=Rt(r,u),o=n[e];
n[e]=n[r],n[r]=o}return n.length=t,n}function ie(n,t,r){var e=Oo(n)?Hn:Ct;return r&&Ur(n,t,r)&&(t=w),(typeof t!="function"||r!==w)&&(t=wr(t,r,3)),e(n,t)}function fe(n,t){var r;if(typeof t!="function"){if(typeof n!="function")throw new Ge(L);var e=n;n=t,t=e}return function(){return 0<--n&&(r=t.apply(this,arguments)),1>=n&&(t=w),r}}function ae(n,t,r){function e(t,r){r&&iu(r),a=p=h=w,t&&(_=ho(),c=n.apply(s,f),p||a||(f=s=w))}function u(){var n=t-(ho()-l);0>=n||n>t?e(h,a):p=su(u,n)}function o(){e(g,p);
}function i(){if(f=arguments,l=ho(),s=this,h=g&&(p||!y),false===v)var r=y&&!p;else{a||y||(_=l);var e=v-(l-_),i=0>=e||e>v;i?(a&&(a=iu(a)),_=l,c=n.apply(s,f)):a||(a=su(o,e))}return i&&p?p=iu(p):p||t===v||(p=su(u,t)),r&&(i=true,c=n.apply(s,f)),!i||p||a||(f=s=w),c}var f,a,c,l,s,p,h,_=0,v=false,g=true;if(typeof n!="function")throw new Ge(L);if(t=0>t?0:+t||0,true===r)var y=true,g=false;else ge(r)&&(y=!!r.leading,v="maxWait"in r&&bu(+r.maxWait||0,t),g="trailing"in r?!!r.trailing:g);return i.cancel=function(){p&&iu(p),a&&iu(a),
_=0,a=p=h=w},i}function ce(n,t){function r(){var e=arguments,u=t?t.apply(this,e):e[0],o=r.cache;return o.has(u)?o.get(u):(e=n.apply(this,e),r.cache=o.set(u,e),e)}if(typeof n!="function"||t&&typeof t!="function")throw new Ge(L);return r.cache=new ce.Cache,r}function le(n,t){if(typeof n!="function")throw new Ge(L);return t=bu(t===w?n.length-1:+t||0,0),function(){for(var r=arguments,e=-1,u=bu(r.length-t,0),o=Be(u);++e<u;)o[e]=r[t+e];switch(t){case 0:return n.call(this,o);case 1:return n.call(this,r[0],o);
case 2:return n.call(this,r[0],r[1],o)}for(u=Be(t+1),e=-1;++e<t;)u[e]=r[e];return u[t]=o,n.apply(this,u)}}function se(n,t){return n>t}function pe(n){return h(n)&&Er(n)&&nu.call(n,"callee")&&!cu.call(n,"callee")}function he(n,t,r,e){return e=(r=typeof r=="function"?Bt(r,e,3):w)?r(n,t):w,e===w?dt(n,t,r):!!e}function _e(n){return h(n)&&typeof n.message=="string"&&ru.call(n)==P}function ve(n){return ge(n)&&ru.call(n)==K}function ge(n){var t=typeof n;return!!n&&("object"==t||"function"==t)}function ye(n){
return null==n?false:ve(n)?uu.test(Qe.call(n)):h(n)&&Rn.test(n)}function de(n){return typeof n=="number"||h(n)&&ru.call(n)==V}function me(n){var t;if(!h(n)||ru.call(n)!=Z||pe(n)||!(nu.call(n,"constructor")||(t=n.constructor,typeof t!="function"||t instanceof t)))return false;var r;return ht(n,function(n,t){r=t}),r===w||nu.call(n,r)}function we(n){return ge(n)&&ru.call(n)==Y}function be(n){return typeof n=="string"||h(n)&&ru.call(n)==G}function xe(n){return h(n)&&Sr(n.length)&&!!Sn[ru.call(n)]}function Ae(n,t){
return n<t}function je(n){var t=n?Bu(n):0;return Sr(t)?t?qn(n):[]:Ee(n)}function ke(n){return et(n,Re(n))}function Ie(n){return gt(n,Re(n))}function Re(n){if(null==n)return[];ge(n)||(n=Ve(n));for(var t=n.length,t=t&&Sr(t)&&(Oo(n)||pe(n))&&t||0,r=n.constructor,e=-1,r=typeof r=="function"&&r.prototype===n,u=Be(t),o=0<t;++e<t;)u[e]=e+"";for(var i in n)o&&Cr(i,t)||"constructor"==i&&(r||!nu.call(n,i))||u.push(i);return u}function Oe(n){n=Br(n);for(var t=-1,r=zo(n),e=r.length,u=Be(e);++t<e;){var o=r[t];
u[t]=[o,n[o]]}return u}function Ee(n){return Ft(n,zo(n))}function Ce(n){return(n=u(n))&&n.replace(En,a).replace(xn,"")}function Ue(n,t){var r="";if(n=u(n),t=+t,1>t||!n||!mu(t))return r;do t%2&&(r+=n),t=yu(t/2),n+=n;while(t);return r}function We(n,t,r){var e=n;return(n=u(n))?(r?Ur(e,t,r):null==t)?n.slice(g(n),y(n)+1):(t+="",n.slice(o(n,t),i(n,t)+1)):n}function $e(n,t,r){return r&&Ur(n,t,r)&&(t=w),n=u(n),n.match(t||Wn)||[]}function Se(n,t,r){return r&&Ur(n,t,r)&&(t=w),h(n)?Ne(n):ut(n,t)}function Fe(n){
return n}function Ne(n){return bt(ot(n,true))}function Te(n,t,r){if(null==r){var e=ge(t),u=e?zo(t):w;((u=u&&u.length?gt(t,u):w)?u.length:e)||(u=false,r=t,t=n,n=this)}u||(u=gt(t,zo(t)));var o=true,e=-1,i=ve(n),f=u.length;false===r?o=false:ge(r)&&"chain"in r&&(o=r.chain);for(;++e<f;){r=u[e];var a=t[r];n[r]=a,i&&(n.prototype[r]=function(t){return function(){var r=this.__chain__;if(o||r){var e=n(this.__wrapped__);return(e.__actions__=qn(this.__actions__)).push({func:t,args:arguments,thisArg:n}),e.__chain__=r,e}return t.apply(n,Jn([this.value()],arguments));
}}(a))}return n}function Le(){}function ze(n){return Wr(n)?jt(n):kt(n)}_=_?Yn.defaults(Zn.Object(),_,Yn.pick(Zn,$n)):Zn;var Be=_.Array,De=_.Date,Me=_.Error,qe=_.Function,Pe=_.Math,Ke=_.Number,Ve=_.Object,Ze=_.RegExp,Ye=_.String,Ge=_.TypeError,Je=Be.prototype,Xe=Ve.prototype,He=Ye.prototype,Qe=qe.prototype.toString,nu=Xe.hasOwnProperty,tu=0,ru=Xe.toString,eu=Zn._,uu=Ze("^"+Qe.call(nu).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),ou=_.ArrayBuffer,iu=_.clearTimeout,fu=_.parseFloat,au=Pe.pow,cu=Xe.propertyIsEnumerable,lu=jr(_,"Set"),su=_.setTimeout,pu=Je.splice,hu=_.Uint8Array,_u=jr(_,"WeakMap"),vu=Pe.ceil,gu=jr(Ve,"create"),yu=Pe.floor,du=jr(Be,"isArray"),mu=_.isFinite,wu=jr(Ve,"keys"),bu=Pe.max,xu=Pe.min,Au=jr(De,"now"),ju=_.parseInt,ku=Pe.random,Iu=Ke.NEGATIVE_INFINITY,Ru=Ke.POSITIVE_INFINITY,Ou=4294967294,Eu=2147483647,Cu=9007199254740991,Uu=_u&&new _u,Wu={};
Nn.support={},Nn.templateSettings={escape:_n,evaluate:vn,interpolate:gn,variable:"",imports:{_:Nn}};var $u=function(){function n(){}return function(t){if(ge(t)){n.prototype=t;var r=new n;n.prototype=w}return r||{}}}(),Su=Vt(_t),Fu=Vt(vt,true),Nu=Zt(),Tu=Zt(true),Lu=Uu?function(n,t){return Uu.set(n,t),n}:Fe,zu=Uu?function(n){return Uu.get(n)}:Le,Bu=jt("length"),Du=function(){var n=0,t=0;return function(r,e){var u=ho(),o=S-(u-t);if(t=u,0<o){if(++n>=$)return r}else n=0;return Lu(r,e)}}(),Mu=le(function(n,t){
return h(n)&&Er(n)?ft(n,pt(t,false,true)):[]}),qu=tr(),Pu=tr(true),Ku=le(function(n){for(var t=n.length,e=t,u=Be(l),o=xr(),i=o===r,f=[];e--;){var a=n[e]=Er(a=n[e])?a:[];u[e]=i&&120<=a.length&&gu&&lu?new Dn(e&&a):null}var i=n[0],c=-1,l=i?i.length:0,s=u[0];n:for(;++c<l;)if(a=i[c],0>(s?Mn(s,a):o(f,a,0))){for(e=t;--e;){var p=u[e];if(0>(p?Mn(p,a):o(n[e],a,0)))continue n}s&&s.push(a),f.push(a)}return f}),Vu=le(function(t,r){r=pt(r);var e=rt(t,r);return It(t,r.sort(n)),e}),Zu=vr(),Yu=vr(true),Gu=le(function(n){return St(pt(n,false,true));
}),Ju=le(function(n,t){return Er(n)?ft(n,t):[]}),Xu=le(Jr),Hu=le(function(n){var t=n.length,r=2<t?n[t-2]:w,e=1<t?n[t-1]:w;return 2<t&&typeof r=="function"?t-=2:(r=1<t&&typeof e=="function"?(--t,e):w,e=w),n.length=t,Xr(n,r,e)}),Qu=le(function(n){return n=pt(n),this.thru(function(t){t=Oo(t)?t:[Br(t)];for(var r=n,e=-1,u=t.length,o=-1,i=r.length,f=Be(u+i);++e<u;)f[e]=t[e];for(;++o<i;)f[e++]=r[o];return f})}),no=le(function(n,t){return rt(n,pt(t))}),to=Pt(function(n,t,r){nu.call(n,r)?++n[r]:n[r]=1}),ro=nr(Su),eo=nr(Fu,true),uo=ur(Pn,Su),oo=ur(function(n,t){
for(var r=n.length;r--&&false!==t(n[r],r,n););return n},Fu),io=Pt(function(n,t,r){nu.call(n,r)?n[r].push(t):n[r]=[t]}),fo=Pt(function(n,t,r){n[r]=t}),ao=le(function(n,t,r){var e=-1,u=typeof t=="function",o=Wr(t),i=Er(n)?Be(n.length):[];return Su(n,function(n){var f=u?t:o&&null!=n?n[t]:w;i[++e]=f?f.apply(n,r):Or(n,t,r)}),i}),co=Pt(function(n,t,r){n[r?0:1].push(t)},function(){return[[],[]]}),lo=lr(Xn,Su),so=lr(function(n,t,r,e){var u=n.length;for(e&&u&&(r=n[--u]);u--;)r=t(r,n[u],u,n);return r},Fu),po=le(function(n,t){
if(null==n)return[];var r=t[2];return r&&Ur(t[0],t[1],r)&&(t.length=1),Wt(n,pt(t),[])}),ho=Au||function(){return(new De).getTime()},_o=le(function(n,t,r){var e=x;if(r.length)var u=v(r,_o.placeholder),e=e|R;return gr(n,e,t,r,u)}),vo=le(function(n,t){t=t.length?pt(t):Ie(n);for(var r=-1,e=t.length;++r<e;){var u=t[r];n[u]=gr(n[u],x,n)}return n}),go=le(function(n,t,r){var e=x|A;if(r.length)var u=v(r,go.placeholder),e=e|R;return gr(t,e,n,r,u)}),yo=Xt(k),mo=Xt(I),wo=le(function(n,t){return it(n,1,t)}),bo=le(function(n,t,r){
return it(n,t,r)}),xo=er(),Ao=er(true),jo=le(function(n,t){if(t=pt(t),typeof n!="function"||!Kn(t,e))throw new Ge(L);var r=t.length;return le(function(e){for(var u=xu(e.length,r);u--;)e[u]=t[u](e[u]);return n.apply(this,e)})}),ko=cr(R),Io=cr(O),Ro=le(function(n,t){return gr(n,C,w,w,w,pt(t))}),Oo=du||function(n){return h(n)&&Sr(n.length)&&ru.call(n)==D},Eo=Kt(At),Co=Kt(function(n,t,r){return r?nt(n,t,r):tt(n,t)}),Uo=Ht(Co,function(n,t){return n===w?t:n}),Wo=Ht(Eo,Fr),$o=rr(_t),So=rr(vt),Fo=or(Nu),No=or(Tu),To=ir(_t),Lo=ir(vt),zo=wu?function(n){
var t=null==n?w:n.constructor;return typeof t=="function"&&t.prototype===n||typeof n!="function"&&Er(n)?Lr(n):ge(n)?wu(n):[]}:Lr,Bo=fr(true),Do=fr(),Mo=le(function(n,t){if(null==n)return{};if("function"!=typeof t[0])return t=Gn(pt(t),Ye),Nr(n,ft(Re(n),t));var r=Bt(t[0],t[1],3);return Tr(n,function(n,t,e){return!r(n,t,e)})}),qo=le(function(n,t){return null==n?{}:"function"==typeof t[0]?Tr(n,Bt(t[0],t[1],3)):Nr(n,pt(t))}),Po=Gt(function(n,t,r){return t=t.toLowerCase(),n+(r?t.charAt(0).toUpperCase()+t.slice(1):t);
}),Ko=Gt(function(n,t,r){return n+(r?"-":"")+t.toLowerCase()}),Vo=ar(),Zo=ar(true),Yo=Gt(function(n,t,r){return n+(r?"_":"")+t.toLowerCase()}),Go=Gt(function(n,t,r){return n+(r?" ":"")+(t.charAt(0).toUpperCase()+t.slice(1))}),Jo=le(function(n,t){try{return n.apply(w,t)}catch(r){return _e(r)?r:new Me(r)}}),Xo=le(function(n,t){return function(r){return Or(r,n,t)}}),Ho=le(function(n,t){return function(r){return Or(n,r,t)}}),Qo=_r("ceil"),ni=_r("floor"),ti=Qt(se,Iu),ri=Qt(Ae,Ru),ei=_r("round");return Nn.prototype=Tn.prototype,
Ln.prototype=$u(Tn.prototype),Ln.prototype.constructor=Ln,zn.prototype=$u(Tn.prototype),zn.prototype.constructor=zn,Bn.prototype["delete"]=function(n){return this.has(n)&&delete this.__data__[n]},Bn.prototype.get=function(n){return"__proto__"==n?w:this.__data__[n]},Bn.prototype.has=function(n){return"__proto__"!=n&&nu.call(this.__data__,n)},Bn.prototype.set=function(n,t){return"__proto__"!=n&&(this.__data__[n]=t),this},Dn.prototype.push=function(n){var t=this.data;typeof n=="string"||ge(n)?t.set.add(n):t.hash[n]=true;
},ce.Cache=Bn,Nn.after=function(n,t){if(typeof t!="function"){if(typeof n!="function")throw new Ge(L);var r=n;n=t,t=r}return n=mu(n=+n)?n:0,function(){return 1>--n?t.apply(this,arguments):void 0}},Nn.ary=function(n,t,r){return r&&Ur(n,t,r)&&(t=w),t=n&&null==t?n.length:bu(+t||0,0),gr(n,E,w,w,w,w,t)},Nn.assign=Co,Nn.at=no,Nn.before=fe,Nn.bind=_o,Nn.bindAll=vo,Nn.bindKey=go,Nn.callback=Se,Nn.chain=Qr,Nn.chunk=function(n,t,r){t=(r?Ur(n,t,r):null==t)?1:bu(yu(t)||1,1),r=0;for(var e=n?n.length:0,u=-1,o=Be(vu(e/t));r<e;)o[++u]=Et(n,r,r+=t);
return o},Nn.compact=function(n){for(var t=-1,r=n?n.length:0,e=-1,u=[];++t<r;){var o=n[t];o&&(u[++e]=o)}return u},Nn.constant=function(n){return function(){return n}},Nn.countBy=to,Nn.create=function(n,t,r){var e=$u(n);return r&&Ur(n,t,r)&&(t=w),t?tt(e,t):e},Nn.curry=yo,Nn.curryRight=mo,Nn.debounce=ae,Nn.defaults=Uo,Nn.defaultsDeep=Wo,Nn.defer=wo,Nn.delay=bo,Nn.difference=Mu,Nn.drop=qr,Nn.dropRight=Pr,Nn.dropRightWhile=function(n,t,r){return n&&n.length?Nt(n,wr(t,r,3),true,true):[]},Nn.dropWhile=function(n,t,r){
return n&&n.length?Nt(n,wr(t,r,3),true):[]},Nn.fill=function(n,t,r,e){var u=n?n.length:0;if(!u)return[];for(r&&typeof r!="number"&&Ur(n,t,r)&&(r=0,e=u),u=n.length,r=null==r?0:+r||0,0>r&&(r=-r>u?0:u+r),e=e===w||e>u?u:+e||0,0>e&&(e+=u),u=r>e?0:e>>>0,r>>>=0;r<u;)n[r++]=t;return n},Nn.filter=re,Nn.flatten=function(n,t,r){var e=n?n.length:0;return r&&Ur(n,t,r)&&(t=false),e?pt(n,t):[]},Nn.flattenDeep=function(n){return n&&n.length?pt(n,true):[]},Nn.flow=xo,Nn.flowRight=Ao,Nn.forEach=uo,Nn.forEachRight=oo,Nn.forIn=Fo,
Nn.forInRight=No,Nn.forOwn=To,Nn.forOwnRight=Lo,Nn.functions=Ie,Nn.groupBy=io,Nn.indexBy=fo,Nn.initial=function(n){return Pr(n,1)},Nn.intersection=Ku,Nn.invert=function(n,t,r){r&&Ur(n,t,r)&&(t=w),r=-1;for(var e=zo(n),u=e.length,o={};++r<u;){var i=e[r],f=n[i];t?nu.call(o,f)?o[f].push(i):o[f]=[i]:o[f]=i}return o},Nn.invoke=ao,Nn.keys=zo,Nn.keysIn=Re,Nn.map=ue,Nn.mapKeys=Bo,Nn.mapValues=Do,Nn.matches=Ne,Nn.matchesProperty=function(n,t){return xt(n,ot(t,true))},Nn.memoize=ce,Nn.merge=Eo,Nn.method=Xo,Nn.methodOf=Ho,
Nn.mixin=Te,Nn.modArgs=jo,Nn.negate=function(n){if(typeof n!="function")throw new Ge(L);return function(){return!n.apply(this,arguments)}},Nn.omit=Mo,Nn.once=function(n){return fe(2,n)},Nn.pairs=Oe,Nn.partial=ko,Nn.partialRight=Io,Nn.partition=co,Nn.pick=qo,Nn.pluck=function(n,t){return ue(n,ze(t))},Nn.property=ze,Nn.propertyOf=function(n){return function(t){return yt(n,Dr(t),t+"")}},Nn.pull=function(){var n=arguments,t=n[0];if(!t||!t.length)return t;for(var r=0,e=xr(),u=n.length;++r<u;)for(var o=0,i=n[r];-1<(o=e(t,i,o));)pu.call(t,o,1);
return t},Nn.pullAt=Vu,Nn.range=function(n,t,r){r&&Ur(n,t,r)&&(t=r=w),n=+n||0,r=null==r?1:+r||0,null==t?(t=n,n=0):t=+t||0;var e=-1;t=bu(vu((t-n)/(r||1)),0);for(var u=Be(t);++e<t;)u[e]=n,n+=r;return u},Nn.rearg=Ro,Nn.reject=function(n,t,r){var e=Oo(n)?Vn:lt;return t=wr(t,r,3),e(n,function(n,r,e){return!t(n,r,e)})},Nn.remove=function(n,t,r){var e=[];if(!n||!n.length)return e;var u=-1,o=[],i=n.length;for(t=wr(t,r,3);++u<i;)r=n[u],t(r,u,n)&&(e.push(r),o.push(u));return It(n,o),e},Nn.rest=Yr,Nn.restParam=le,
Nn.set=function(n,t,r){if(null==n)return n;var e=t+"";t=null!=n[e]||Wr(t,n)?[e]:Dr(t);for(var e=-1,u=t.length,o=u-1,i=n;null!=i&&++e<u;){var f=t[e];ge(i)&&(e==o?i[f]=r:null==i[f]&&(i[f]=Cr(t[e+1])?[]:{})),i=i[f]}return n},Nn.shuffle=function(n){return oe(n,Ru)},Nn.slice=function(n,t,r){var e=n?n.length:0;return e?(r&&typeof r!="number"&&Ur(n,t,r)&&(t=0,r=e),Et(n,t,r)):[]},Nn.sortBy=function(n,t,r){if(null==n)return[];r&&Ur(n,t,r)&&(t=w);var e=-1;return t=wr(t,r,3),n=wt(n,function(n,r,u){return{a:t(n,r,u),
b:++e,c:n}}),Ut(n,f)},Nn.sortByAll=po,Nn.sortByOrder=function(n,t,r,e){return null==n?[]:(e&&Ur(t,r,e)&&(r=w),Oo(t)||(t=null==t?[]:[t]),Oo(r)||(r=null==r?[]:[r]),Wt(n,t,r))},Nn.spread=function(n){if(typeof n!="function")throw new Ge(L);return function(t){return n.apply(this,t)}},Nn.take=function(n,t,r){return n&&n.length?((r?Ur(n,t,r):null==t)&&(t=1),Et(n,0,0>t?0:t)):[]},Nn.takeRight=function(n,t,r){var e=n?n.length:0;return e?((r?Ur(n,t,r):null==t)&&(t=1),t=e-(+t||0),Et(n,0>t?0:t)):[]},Nn.takeRightWhile=function(n,t,r){
return n&&n.length?Nt(n,wr(t,r,3),false,true):[]},Nn.takeWhile=function(n,t,r){return n&&n.length?Nt(n,wr(t,r,3)):[]},Nn.tap=function(n,t,r){return t.call(r,n),n},Nn.throttle=function(n,t,r){var e=true,u=true;if(typeof n!="function")throw new Ge(L);return false===r?e=false:ge(r)&&(e="leading"in r?!!r.leading:e,u="trailing"in r?!!r.trailing:u),ae(n,t,{leading:e,maxWait:+t,trailing:u})},Nn.thru=ne,Nn.times=function(n,t,r){if(n=yu(n),1>n||!mu(n))return[];var e=-1,u=Be(xu(n,4294967295));for(t=Bt(t,r,1);++e<n;)4294967295>e?u[e]=t(e):t(e);
return u},Nn.toArray=je,Nn.toPlainObject=ke,Nn.transform=function(n,t,r,e){var u=Oo(n)||xe(n);return t=wr(t,e,4),null==r&&(u||ge(n)?(e=n.constructor,r=u?Oo(n)?new e:[]:$u(ve(e)?e.prototype:w)):r={}),(u?Pn:_t)(n,function(n,e,u){return t(r,n,e,u)}),r},Nn.union=Gu,Nn.uniq=Gr,Nn.unzip=Jr,Nn.unzipWith=Xr,Nn.values=Ee,Nn.valuesIn=function(n){return Ft(n,Re(n))},Nn.where=function(n,t){return re(n,bt(t))},Nn.without=Ju,Nn.wrap=function(n,t){return t=null==t?Fe:t,gr(t,R,w,[n],[])},Nn.xor=function(){for(var n=-1,t=arguments.length;++n<t;){
var r=arguments[n];if(Er(r))var e=e?Jn(ft(e,r),ft(r,e)):r}return e?St(e):[]},Nn.zip=Xu,Nn.zipObject=Hr,Nn.zipWith=Hu,Nn.backflow=Ao,Nn.collect=ue,Nn.compose=Ao,Nn.each=uo,Nn.eachRight=oo,Nn.extend=Co,Nn.iteratee=Se,Nn.methods=Ie,Nn.object=Hr,Nn.select=re,Nn.tail=Yr,Nn.unique=Gr,Te(Nn,Nn),Nn.add=function(n,t){return(+n||0)+(+t||0)},Nn.attempt=Jo,Nn.camelCase=Po,Nn.capitalize=function(n){return(n=u(n))&&n.charAt(0).toUpperCase()+n.slice(1)},Nn.ceil=Qo,Nn.clone=function(n,t,r,e){return t&&typeof t!="boolean"&&Ur(n,t,r)?t=false:typeof t=="function"&&(e=r,
r=t,t=false),typeof r=="function"?ot(n,t,Bt(r,e,3)):ot(n,t)},Nn.cloneDeep=function(n,t,r){return typeof t=="function"?ot(n,true,Bt(t,r,3)):ot(n,true)},Nn.deburr=Ce,Nn.endsWith=function(n,t,r){n=u(n),t+="";var e=n.length;return r=r===w?e:xu(0>r?0:+r||0,e),r-=t.length,0<=r&&n.indexOf(t,r)==r},Nn.escape=function(n){return(n=u(n))&&hn.test(n)?n.replace(sn,c):n},Nn.escapeRegExp=function(n){return(n=u(n))&&bn.test(n)?n.replace(wn,l):n||"(?:)"},Nn.every=te,Nn.find=ro,Nn.findIndex=qu,Nn.findKey=$o,Nn.findLast=eo,
Nn.findLastIndex=Pu,Nn.findLastKey=So,Nn.findWhere=function(n,t){return ro(n,bt(t))},Nn.first=Kr,Nn.floor=ni,Nn.get=function(n,t,r){return n=null==n?w:yt(n,Dr(t),t+""),n===w?r:n},Nn.gt=se,Nn.gte=function(n,t){return n>=t},Nn.has=function(n,t){if(null==n)return false;var r=nu.call(n,t);if(!r&&!Wr(t)){if(t=Dr(t),n=1==t.length?n:yt(n,Et(t,0,-1)),null==n)return false;t=Zr(t),r=nu.call(n,t)}return r||Sr(n.length)&&Cr(t,n.length)&&(Oo(n)||pe(n))},Nn.identity=Fe,Nn.includes=ee,Nn.indexOf=Vr,Nn.inRange=function(n,t,r){
return t=+t||0,r===w?(r=t,t=0):r=+r||0,n>=xu(t,r)&&n<bu(t,r)},Nn.isArguments=pe,Nn.isArray=Oo,Nn.isBoolean=function(n){return true===n||false===n||h(n)&&ru.call(n)==M},Nn.isDate=function(n){return h(n)&&ru.call(n)==q},Nn.isElement=function(n){return!!n&&1===n.nodeType&&h(n)&&!me(n)},Nn.isEmpty=function(n){return null==n?true:Er(n)&&(Oo(n)||be(n)||pe(n)||h(n)&&ve(n.splice))?!n.length:!zo(n).length},Nn.isEqual=he,Nn.isError=_e,Nn.isFinite=function(n){return typeof n=="number"&&mu(n)},Nn.isFunction=ve,Nn.isMatch=function(n,t,r,e){
return r=typeof r=="function"?Bt(r,e,3):w,mt(n,Ar(t),r)},Nn.isNaN=function(n){return de(n)&&n!=+n},Nn.isNative=ye,Nn.isNull=function(n){return null===n},Nn.isNumber=de,Nn.isObject=ge,Nn.isPlainObject=me,Nn.isRegExp=we,Nn.isString=be,Nn.isTypedArray=xe,Nn.isUndefined=function(n){return n===w},Nn.kebabCase=Ko,Nn.last=Zr,Nn.lastIndexOf=function(n,t,r){var e=n?n.length:0;if(!e)return-1;var u=e;if(typeof r=="number")u=(0>r?bu(e+r,0):xu(r||0,e-1))+1;else if(r)return u=Lt(n,t,true)-1,n=n[u],(t===t?t===n:n!==n)?u:-1;
if(t!==t)return p(n,u,true);for(;u--;)if(n[u]===t)return u;return-1},Nn.lt=Ae,Nn.lte=function(n,t){return n<=t},Nn.max=ti,Nn.min=ri,Nn.noConflict=function(){return Zn._=eu,this},Nn.noop=Le,Nn.now=ho,Nn.pad=function(n,t,r){n=u(n),t=+t;var e=n.length;return e<t&&mu(t)?(e=(t-e)/2,t=yu(e),e=vu(e),r=pr("",e,r),r.slice(0,t)+n+r):n},Nn.padLeft=Vo,Nn.padRight=Zo,Nn.parseInt=function(n,t,r){return(r?Ur(n,t,r):null==t)?t=0:t&&(t=+t),n=We(n),ju(n,t||(In.test(n)?16:10))},Nn.random=function(n,t,r){r&&Ur(n,t,r)&&(t=r=w);
var e=null==n,u=null==t;return null==r&&(u&&typeof n=="boolean"?(r=n,n=1):typeof t=="boolean"&&(r=t,u=true)),e&&u&&(t=1,u=false),n=+n||0,u?(t=n,n=0):t=+t||0,r||n%1||t%1?(r=ku(),xu(n+r*(t-n+fu("1e-"+((r+"").length-1))),t)):Rt(n,t)},Nn.reduce=lo,Nn.reduceRight=so,Nn.repeat=Ue,Nn.result=function(n,t,r){var e=null==n?w:n[t];return e===w&&(null==n||Wr(t,n)||(t=Dr(t),n=1==t.length?n:yt(n,Et(t,0,-1)),e=null==n?w:n[Zr(t)]),e=e===w?r:e),ve(e)?e.call(n):e},Nn.round=ei,Nn.runInContext=m,Nn.size=function(n){var t=n?Bu(n):0;
return Sr(t)?t:zo(n).length},Nn.snakeCase=Yo,Nn.some=ie,Nn.sortedIndex=Zu,Nn.sortedLastIndex=Yu,Nn.startCase=Go,Nn.startsWith=function(n,t,r){return n=u(n),r=null==r?0:xu(0>r?0:+r||0,n.length),n.lastIndexOf(t,r)==r},Nn.sum=function(n,t,r){if(r&&Ur(n,t,r)&&(t=w),t=wr(t,r,3),1==t.length){n=Oo(n)?n:zr(n),r=n.length;for(var e=0;r--;)e+=+t(n[r])||0;n=e}else n=$t(n,t);return n},Nn.template=function(n,t,r){var e=Nn.templateSettings;r&&Ur(n,t,r)&&(t=r=w),n=u(n),t=nt(tt({},r||t),e,Qn),r=nt(tt({},t.imports),e.imports,Qn);
var o,i,f=zo(r),a=Ft(r,f),c=0;r=t.interpolate||Cn;var l="__p+='";r=Ze((t.escape||Cn).source+"|"+r.source+"|"+(r===gn?jn:Cn).source+"|"+(t.evaluate||Cn).source+"|$","g");var p="sourceURL"in t?"//# sourceURL="+t.sourceURL+"\n":"";if(n.replace(r,function(t,r,e,u,f,a){return e||(e=u),l+=n.slice(c,a).replace(Un,s),r&&(o=true,l+="'+__e("+r+")+'"),f&&(i=true,l+="';"+f+";\n__p+='"),e&&(l+="'+((__t=("+e+"))==null?'':__t)+'"),c=a+t.length,t}),l+="';",(t=t.variable)||(l="with(obj){"+l+"}"),l=(i?l.replace(fn,""):l).replace(an,"$1").replace(cn,"$1;"),
l="function("+(t||"obj")+"){"+(t?"":"obj||(obj={});")+"var __t,__p=''"+(o?",__e=_.escape":"")+(i?",__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}":";")+l+"return __p}",t=Jo(function(){return qe(f,p+"return "+l).apply(w,a)}),t.source=l,_e(t))throw t;return t},Nn.trim=We,Nn.trimLeft=function(n,t,r){var e=n;return(n=u(n))?n.slice((r?Ur(e,t,r):null==t)?g(n):o(n,t+"")):n},Nn.trimRight=function(n,t,r){var e=n;return(n=u(n))?(r?Ur(e,t,r):null==t)?n.slice(0,y(n)+1):n.slice(0,i(n,t+"")+1):n;
},Nn.trunc=function(n,t,r){r&&Ur(n,t,r)&&(t=w);var e=U;if(r=W,null!=t)if(ge(t)){var o="separator"in t?t.separator:o,e="length"in t?+t.length||0:e;r="omission"in t?u(t.omission):r}else e=+t||0;if(n=u(n),e>=n.length)return n;if(e-=r.length,1>e)return r;if(t=n.slice(0,e),null==o)return t+r;if(we(o)){if(n.slice(e).search(o)){var i,f=n.slice(0,e);for(o.global||(o=Ze(o.source,(kn.exec(o)||"")+"g")),o.lastIndex=0;n=o.exec(f);)i=n.index;t=t.slice(0,null==i?e:i)}}else n.indexOf(o,e)!=e&&(o=t.lastIndexOf(o),
-1<o&&(t=t.slice(0,o)));return t+r},Nn.unescape=function(n){return(n=u(n))&&pn.test(n)?n.replace(ln,d):n},Nn.uniqueId=function(n){var t=++tu;return u(n)+t},Nn.words=$e,Nn.all=te,Nn.any=ie,Nn.contains=ee,Nn.eq=he,Nn.detect=ro,Nn.foldl=lo,Nn.foldr=so,Nn.head=Kr,Nn.include=ee,Nn.inject=lo,Te(Nn,function(){var n={};return _t(Nn,function(t,r){Nn.prototype[r]||(n[r]=t)}),n}(),false),Nn.sample=oe,Nn.prototype.sample=function(n){return this.__chain__||null!=n?this.thru(function(t){return oe(t,n)}):oe(this.value());
},Nn.VERSION=b,Pn("bind bindKey curry curryRight partial partialRight".split(" "),function(n){Nn[n].placeholder=Nn}),Pn(["drop","take"],function(n,t){zn.prototype[n]=function(r){var e=this.__filtered__;if(e&&!t)return new zn(this);r=null==r?1:bu(yu(r)||0,0);var u=this.clone();return e?u.__takeCount__=xu(u.__takeCount__,r):u.__views__.push({size:r,type:n+(0>u.__dir__?"Right":"")}),u},zn.prototype[n+"Right"]=function(t){return this.reverse()[n](t).reverse()}}),Pn(["filter","map","takeWhile"],function(n,t){
var r=t+1,e=r!=T;zn.prototype[n]=function(n,t){var u=this.clone();return u.__iteratees__.push({iteratee:wr(n,t,1),type:r}),u.__filtered__=u.__filtered__||e,u}}),Pn(["first","last"],function(n,t){var r="take"+(t?"Right":"");zn.prototype[n]=function(){return this[r](1).value()[0]}}),Pn(["initial","rest"],function(n,t){var r="drop"+(t?"":"Right");zn.prototype[n]=function(){return this.__filtered__?new zn(this):this[r](1)}}),Pn(["pluck","where"],function(n,t){var r=t?"filter":"map",e=t?bt:ze;zn.prototype[n]=function(n){
return this[r](e(n))}}),zn.prototype.compact=function(){return this.filter(Fe)},zn.prototype.reject=function(n,t){return n=wr(n,t,1),this.filter(function(t){return!n(t)})},zn.prototype.slice=function(n,t){n=null==n?0:+n||0;var r=this;return r.__filtered__&&(0<n||0>t)?new zn(r):(0>n?r=r.takeRight(-n):n&&(r=r.drop(n)),t!==w&&(t=+t||0,r=0>t?r.dropRight(-t):r.take(t-n)),r)},zn.prototype.takeRightWhile=function(n,t){return this.reverse().takeWhile(n,t).reverse()},zn.prototype.toArray=function(){return this.take(Ru);
},_t(zn.prototype,function(n,t){var r=/^(?:filter|map|reject)|While$/.test(t),e=/^(?:first|last)$/.test(t),u=Nn[e?"take"+("last"==t?"Right":""):t];u&&(Nn.prototype[t]=function(){function t(n){return e&&i?u(n,1)[0]:u.apply(w,Jn([n],o))}var o=e?[1]:arguments,i=this.__chain__,f=this.__wrapped__,a=!!this.__actions__.length,c=f instanceof zn,l=o[0],s=c||Oo(f);return s&&r&&typeof l=="function"&&1!=l.length&&(c=s=false),l={func:ne,args:[t],thisArg:w},a=c&&!a,e&&!i?a?(f=f.clone(),f.__actions__.push(l),n.call(f)):u.call(w,this.value())[0]:!e&&s?(f=a?f:new zn(this),
f=n.apply(f,o),f.__actions__.push(l),new Ln(f,i)):this.thru(t)})}),Pn("join pop push replace shift sort splice split unshift".split(" "),function(n){var t=(/^(?:replace|split)$/.test(n)?He:Je)[n],r=/^(?:push|sort|unshift)$/.test(n)?"tap":"thru",e=/^(?:join|pop|replace|shift)$/.test(n);Nn.prototype[n]=function(){var n=arguments;return e&&!this.__chain__?t.apply(this.value(),n):this[r](function(r){return t.apply(r,n)})}}),_t(zn.prototype,function(n,t){var r=Nn[t];if(r){var e=r.name+"";(Wu[e]||(Wu[e]=[])).push({
name:t,func:r})}}),Wu[sr(w,A).name]=[{name:"wrapper",func:w}],zn.prototype.clone=function(){var n=new zn(this.__wrapped__);return n.__actions__=qn(this.__actions__),n.__dir__=this.__dir__,n.__filtered__=this.__filtered__,n.__iteratees__=qn(this.__iteratees__),n.__takeCount__=this.__takeCount__,n.__views__=qn(this.__views__),n},zn.prototype.reverse=function(){if(this.__filtered__){var n=new zn(this);n.__dir__=-1,n.__filtered__=true}else n=this.clone(),n.__dir__*=-1;return n},zn.prototype.value=function(){
var n,t=this.__wrapped__.value(),r=this.__dir__,e=Oo(t),u=0>r,o=e?t.length:0;n=o;for(var i=this.__views__,f=0,a=-1,c=i.length;++a<c;){var l=i[a],s=l.size;switch(l.type){case"drop":f+=s;break;case"dropRight":n-=s;break;case"take":n=xu(n,f+s);break;case"takeRight":f=bu(f,n-s)}}if(n={start:f,end:n},i=n.start,f=n.end,n=f-i,u=u?f:i-1,i=this.__iteratees__,f=i.length,a=0,c=xu(n,this.__takeCount__),!e||o<F||o==n&&c==n)return Tt(t,this.__actions__);e=[];n:for(;n--&&a<c;){for(u+=r,o=-1,l=t[u];++o<f;){var p=i[o],s=p.type,p=p.iteratee(l);
if(s==T)l=p;else if(!p){if(s==N)continue n;break n}}e[a++]=l}return e},Nn.prototype.chain=function(){return Qr(this)},Nn.prototype.commit=function(){return new Ln(this.value(),this.__chain__)},Nn.prototype.concat=Qu,Nn.prototype.plant=function(n){for(var t,r=this;r instanceof Tn;){var e=Mr(r);t?u.__wrapped__=e:t=e;var u=e,r=r.__wrapped__}return u.__wrapped__=n,t},Nn.prototype.reverse=function(){function n(n){return n.reverse()}var t=this.__wrapped__;return t instanceof zn?(this.__actions__.length&&(t=new zn(this)),
t=t.reverse(),t.__actions__.push({func:ne,args:[n],thisArg:w}),new Ln(t,this.__chain__)):this.thru(n)},Nn.prototype.toString=function(){return this.value()+""},Nn.prototype.run=Nn.prototype.toJSON=Nn.prototype.valueOf=Nn.prototype.value=function(){return Tt(this.__wrapped__,this.__actions__)},Nn.prototype.collect=Nn.prototype.map,Nn.prototype.head=Nn.prototype.first,Nn.prototype.select=Nn.prototype.filter,Nn.prototype.tail=Nn.prototype.rest,Nn}var w,b="3.10.1",x=1,A=2,j=4,k=8,I=16,R=32,O=64,E=128,C=256,U=30,W="...",$=150,S=16,F=200,N=1,T=2,L="Expected a function",z="__lodash_placeholder__",B="[object Arguments]",D="[object Array]",M="[object Boolean]",q="[object Date]",P="[object Error]",K="[object Function]",V="[object Number]",Z="[object Object]",Y="[object RegExp]",G="[object String]",J="[object ArrayBuffer]",X="[object Float32Array]",H="[object Float64Array]",Q="[object Int8Array]",nn="[object Int16Array]",tn="[object Int32Array]",rn="[object Uint8Array]",en="[object Uint8ClampedArray]",un="[object Uint16Array]",on="[object Uint32Array]",fn=/\b__p\+='';/g,an=/\b(__p\+=)''\+/g,cn=/(__e\(.*?\)|\b__t\))\+'';/g,ln=/&(?:amp|lt|gt|quot|#39|#96);/g,sn=/[&<>"'`]/g,pn=RegExp(ln.source),hn=RegExp(sn.source),_n=/<%-([\s\S]+?)%>/g,vn=/<%([\s\S]+?)%>/g,gn=/<%=([\s\S]+?)%>/g,yn=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\n\\]|\\.)*?\1)\]/,dn=/^\w*$/,mn=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\n\\]|\\.)*?)\2)\]/g,wn=/^[:!,]|[\\^$.*+?()[\]{}|\/]|(^[0-9a-fA-Fnrtuvx])|([\n\r\u2028\u2029])/g,bn=RegExp(wn.source),xn=/[\u0300-\u036f\ufe20-\ufe23]/g,An=/\\(\\)?/g,jn=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,kn=/\w*$/,In=/^0[xX]/,Rn=/^\[object .+?Constructor\]$/,On=/^\d+$/,En=/[\xc0-\xd6\xd8-\xde\xdf-\xf6\xf8-\xff]/g,Cn=/($^)/,Un=/['\n\r\u2028\u2029\\]/g,Wn=RegExp("[A-Z\\xc0-\\xd6\\xd8-\\xde]+(?=[A-Z\\xc0-\\xd6\\xd8-\\xde][a-z\\xdf-\\xf6\\xf8-\\xff]+)|[A-Z\\xc0-\\xd6\\xd8-\\xde]?[a-z\\xdf-\\xf6\\xf8-\\xff]+|[A-Z\\xc0-\\xd6\\xd8-\\xde]+|[0-9]+","g"),$n="Array ArrayBuffer Date Error Float32Array Float64Array Function Int8Array Int16Array Int32Array Math Number Object RegExp Set String _ clearTimeout isFinite parseFloat parseInt setTimeout TypeError Uint8Array Uint8ClampedArray Uint16Array Uint32Array WeakMap".split(" "),Sn={};
Sn[X]=Sn[H]=Sn[Q]=Sn[nn]=Sn[tn]=Sn[rn]=Sn[en]=Sn[un]=Sn[on]=true,Sn[B]=Sn[D]=Sn[J]=Sn[M]=Sn[q]=Sn[P]=Sn[K]=Sn["[object Map]"]=Sn[V]=Sn[Z]=Sn[Y]=Sn["[object Set]"]=Sn[G]=Sn["[object WeakMap]"]=false;var Fn={};Fn[B]=Fn[D]=Fn[J]=Fn[M]=Fn[q]=Fn[X]=Fn[H]=Fn[Q]=Fn[nn]=Fn[tn]=Fn[V]=Fn[Z]=Fn[Y]=Fn[G]=Fn[rn]=Fn[en]=Fn[un]=Fn[on]=true,Fn[P]=Fn[K]=Fn["[object Map]"]=Fn["[object Set]"]=Fn["[object WeakMap]"]=false;var Nn={"\xc0":"A","\xc1":"A","\xc2":"A","\xc3":"A","\xc4":"A","\xc5":"A","\xe0":"a","\xe1":"a","\xe2":"a",
"\xe3":"a","\xe4":"a","\xe5":"a","\xc7":"C","\xe7":"c","\xd0":"D","\xf0":"d","\xc8":"E","\xc9":"E","\xca":"E","\xcb":"E","\xe8":"e","\xe9":"e","\xea":"e","\xeb":"e","\xcc":"I","\xcd":"I","\xce":"I","\xcf":"I","\xec":"i","\xed":"i","\xee":"i","\xef":"i","\xd1":"N","\xf1":"n","\xd2":"O","\xd3":"O","\xd4":"O","\xd5":"O","\xd6":"O","\xd8":"O","\xf2":"o","\xf3":"o","\xf4":"o","\xf5":"o","\xf6":"o","\xf8":"o","\xd9":"U","\xda":"U","\xdb":"U","\xdc":"U","\xf9":"u","\xfa":"u","\xfb":"u","\xfc":"u","\xdd":"Y",
"\xfd":"y","\xff":"y","\xc6":"Ae","\xe6":"ae","\xde":"Th","\xfe":"th","\xdf":"ss"},Tn={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","`":"&#96;"},Ln={"&amp;":"&","&lt;":"<","&gt;":">","&quot;":'"',"&#39;":"'","&#96;":"`"},zn={"function":true,object:true},Bn={0:"x30",1:"x31",2:"x32",3:"x33",4:"x34",5:"x35",6:"x36",7:"x37",8:"x38",9:"x39",A:"x41",B:"x42",C:"x43",D:"x44",E:"x45",F:"x46",a:"x61",b:"x62",c:"x63",d:"x64",e:"x65",f:"x66",n:"x6e",r:"x72",t:"x74",u:"x75",v:"x76",x:"x78"},Dn={"\\":"\\",
"'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},Mn=zn[typeof exports]&&exports&&!exports.nodeType&&exports,qn=zn[typeof module]&&module&&!module.nodeType&&module,Pn=zn[typeof self]&&self&&self.Object&&self,Kn=zn[typeof window]&&window&&window.Object&&window,Vn=qn&&qn.exports===Mn&&Mn,Zn=Mn&&qn&&typeof global=="object"&&global&&global.Object&&global||Kn!==(this&&this.window)&&Kn||Pn||this,Yn=m();typeof define=="function"&&typeof define.amd=="object"&&define.amd?(Zn._=Yn, define(function(){
return Yn})):Mn&&qn?Vn?(qn.exports=Yn)._=Yn:Mn._=Yn:Zn._=Yn}).call(this);
/*
* A JavaScript implementation of the SHA256 hash function.
*
* FILE:	sha256.js
* VERSION:	0.8
* AUTHOR:	Christoph Bichlmeier <informatik@zombiearena.de>
*
* NOTE: This version is not tested thoroughly!
*
* Copyright (c) 2003, Christoph Bichlmeier
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
*    notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
*    notice, this list of conditions and the following disclaimer in the
*    documentation and/or other materials provided with the distribution.
* 3. Neither the name of the copyright holder nor the names of contributors
*    may be used to endorse or promote products derived from this software
*    without specific prior written permission.
*
* ======================================================================
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHORS ''AS IS'' AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

/* SHA256 logical functions */
function rotateRight(n,x) {
	return ((x >>> n) | (x << (32 - n)));
}
function choice(x,y,z) {
	return ((x & y) ^ (~x & z));
}
function majority(x,y,z) {
	return ((x & y) ^ (x & z) ^ (y & z));
}
function sha256_Sigma0(x) {
	return (rotateRight(2, x) ^ rotateRight(13, x) ^ rotateRight(22, x));
}
function sha256_Sigma1(x) {
	return (rotateRight(6, x) ^ rotateRight(11, x) ^ rotateRight(25, x));
}
function sha256_sigma0(x) {
	return (rotateRight(7, x) ^ rotateRight(18, x) ^ (x >>> 3));
}
function sha256_sigma1(x) {
	return (rotateRight(17, x) ^ rotateRight(19, x) ^ (x >>> 10));
}
function sha256_expand(W, j) {
	return (W[j&0x0f] += sha256_sigma1(W[(j+14)&0x0f]) + W[(j+9)&0x0f] + 
sha256_sigma0(W[(j+1)&0x0f]));
}

/* Hash constant words K: */
var K256 = new Array(
	0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5,
	0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
	0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3,
	0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
	0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc,
	0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
	0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7,
	0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,
	0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13,
	0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,
	0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3,
	0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
	0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5,
	0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,
	0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208,
	0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2
);

/* global arrays */
var ihash, count, buffer;
var sha256_hex_digits = "0123456789abcdef";

/* Add 32-bit integers with 16-bit operations (bug in some JS-interpreters: 
overflow) */
function safe_add(x, y)
{
	var lsw = (x & 0xffff) + (y & 0xffff);
	var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
	return (msw << 16) | (lsw & 0xffff);
}

/* Initialise the SHA256 computation */
function sha256_init() {
	ihash = new Array(8);
	count = new Array(2);
	buffer = new Array(64);
	count[0] = count[1] = 0;
	ihash[0] = 0x6a09e667;
	ihash[1] = 0xbb67ae85;
	ihash[2] = 0x3c6ef372;
	ihash[3] = 0xa54ff53a;
	ihash[4] = 0x510e527f;
	ihash[5] = 0x9b05688c;
	ihash[6] = 0x1f83d9ab;
	ihash[7] = 0x5be0cd19;
}

/* Transform a 512-bit message block */
function sha256_transform() {
	var a, b, c, d, e, f, g, h, T1, T2;
	var W = new Array(16);

	/* Initialize registers with the previous intermediate value */
	a = ihash[0];
	b = ihash[1];
	c = ihash[2];
	d = ihash[3];
	e = ihash[4];
	f = ihash[5];
	g = ihash[6];
	h = ihash[7];

        /* make 32-bit words */
	for(var i=0; i<16; i++)
		W[i] = ((buffer[(i<<2)+3]) | (buffer[(i<<2)+2] << 8) | (buffer[(i<<2)+1] 
<< 16) | (buffer[i<<2] << 24));

        for(var j=0; j<64; j++) {
		T1 = h + sha256_Sigma1(e) + choice(e, f, g) + K256[j];
		if(j < 16) T1 += W[j];
		else T1 += sha256_expand(W, j);
		T2 = sha256_Sigma0(a) + majority(a, b, c);
		h = g;
		g = f;
		f = e;
		e = safe_add(d, T1);
		d = c;
		c = b;
		b = a;
		a = safe_add(T1, T2);
        }

	/* Compute the current intermediate hash value */
	ihash[0] += a;
	ihash[1] += b;
	ihash[2] += c;
	ihash[3] += d;
	ihash[4] += e;
	ihash[5] += f;
	ihash[6] += g;
	ihash[7] += h;
}

/* Read the next chunk of data and update the SHA256 computation */
function sha256_update(data, inputLen) {
	var i, index, curpos = 0;
	/* Compute number of bytes mod 64 */
	index = ((count[0] >> 3) & 0x3f);
        var remainder = (inputLen & 0x3f);

	/* Update number of bits */
	if ((count[0] += (inputLen << 3)) < (inputLen << 3)) count[1]++;
	count[1] += (inputLen >> 29);

	/* Transform as many times as possible */
	for(i=0; i+63<inputLen; i+=64) {
                for(var j=index; j<64; j++)
			buffer[j] = data.charCodeAt(curpos++);
		sha256_transform();
		index = 0;
	}

	/* Buffer remaining input */
	for(var j=0; j<remainder; j++)
		buffer[j] = data.charCodeAt(curpos++);
}

/* Finish the computation by operations such as padding */
function sha256_final() {
	var index = ((count[0] >> 3) & 0x3f);
        buffer[index++] = 0x80;
        if(index <= 56) {
		for(var i=index; i<56; i++)
			buffer[i] = 0;
        } else {
		for(var i=index; i<64; i++)
			buffer[i] = 0;
                sha256_transform();
                for(var i=0; i<56; i++)
			buffer[i] = 0;
	}
        buffer[56] = (count[1] >>> 24) & 0xff;
        buffer[57] = (count[1] >>> 16) & 0xff;
        buffer[58] = (count[1] >>> 8) & 0xff;
        buffer[59] = count[1] & 0xff;
        buffer[60] = (count[0] >>> 24) & 0xff;
        buffer[61] = (count[0] >>> 16) & 0xff;
        buffer[62] = (count[0] >>> 8) & 0xff;
        buffer[63] = count[0] & 0xff;
        sha256_transform();
}

/* Split the internal hash values into an array of bytes */
function sha256_encode_bytes() {
        var j=0;
        var output = new Array(32);
	for(var i=0; i<8; i++) {
		output[j++] = ((ihash[i] >>> 24) & 0xff);
		output[j++] = ((ihash[i] >>> 16) & 0xff);
		output[j++] = ((ihash[i] >>> 8) & 0xff);
		output[j++] = (ihash[i] & 0xff);
	}
	return output;
}

/* Get the internal hash as a hex string */
function sha256_encode_hex() {
	var output = new String();
	for(var i=0; i<8; i++) {
		for(var j=28; j>=0; j-=4)
			output += sha256_hex_digits.charAt((ihash[i] >>> j) & 0x0f);
	}
	return output;
}

/* Main function: returns a hex string representing the SHA256 value of the 
given data */
function sha256_digest(data) {
	sha256_init();
	sha256_update(data, data.length);
	sha256_final();
        return sha256_encode_hex();
}

/* test if the JS-interpreter is working properly */
function sha256_self_test()
{
	return sha256_digest("message digest") == 
"f7846f55cf23e14eebeab5b4e1550cad5b509e3348fbc4efa3a1413d393cb650";
}



function funnyTracker(params) {
  $.ajax({
    type: "POST",
    data: "data=" + JSON.stringify(params),
    url: "/tracker/upEvent",
    contentType: "application/x-www-form-urlencoded; charset=UTF-8"
  });
}

function taskLoger() {
  if (location.pathname !== localStorage.getItem("taskEntrance")) return;

  if (localStorage.getItem("st")) {
    funnyTracker({
      projectId: "event101",
      pointId: "1",
      shiJian: new Date().getTime() - localStorage.getItem("st")
    });
    localStorage.removeItem("st");
    localStorage.removeItem("taskEntrance");
  }
}

(function (global) {

    var objectEach = function (obj, fn , scope  ) {
        for (var x in obj)
            fn.call( scope, x, obj[x] );
    };

    var arrayEach = Array.prototype.forEach ? function (array, fn ,scope) {
        return array.forEach( fn ,scope )
    } : function (obj, fn , scope) {
        for (var i = 0 , len = obj && obj.length || 0; i < len; i++)
            fn.call( scope , obj[i], i);
    };

    var extend = function (params, notOverridden) {
        var me = this;
        objectEach(params, function (name, value) {
            var prev = me[ name ];
            if (prev && notOverridden === true)
                return;
            me[ name ] = value;
            if (typeof value === 'function') {
                value.$name = name;
                value.$owner = this;
                if (prev)
                    value.$prev = prev;
            }
        });
    };

    var ns = function ( name , root ) {
        var part = root || global,
            parts = name && name.split('.') || [];

        arrayEach(parts, function (partName) {
            if (partName) {
                part = part[ partName ] || ( part[ partName ] = {});
            }
        });

        return part;
    };


    /**
     * @class XNative
     * @name XNative
     * @classdesc Base Class , All classes created by XClass inherit from XNative
     * @param {Object} params The constructor parameters.
     */

    var XNative = function (params) {

    };

    /**
     * @name XNative.mixin
     * @function
     * @desc mixin
     * @param {XNative|Object} mixinClass
     * When mixin class is XNative , the mixin scope will be 'this' ( the mixed-in-instance )
     * or mixin class is object like { name : 'MixinClass' , mixin : MixinClass } , the mixin scope will be this.mixins.MixinClass
     *
     * @returns self
     */

    XNative.mixin = function ( mixinClass , name  ) {
        this.mixins.push( { name : name , mixin : mixinClass } );
        return this;
    };

    /**
     * @name XNative.implement
     * @function
     * @desc implement functions to class
     * @param {Object} params
     * @returns self
     */
    XNative.implement = function ( params , safe ) {
        extend.call(this.prototype, params , safe );
        return this;
    };


    /**
     * @name XNative#implement
     * @function
     * @desc implement functions to instance
     * @param {Object} params
     * @returns self
     */

    XNative.prototype.implement = function ( params , safe ) {
        extend.call(this, params , safe );
        return this;
    };


    /**
     * @name XNative#parent
     * @function
     * @desc call super class's function having the same function name
     * @returns {Object}
     */
    XNative.prototype.parent = function () {
        var caller = this.parent.caller ,
            func = caller.$prev;
        if (!func)
            throw new Error('can not call parent');
        else {
            return func.apply(this, arguments);
        }
    };

    var PROCESSOR = {
        'statics':function (newClass, methods) {
            objectEach(methods, function (k, v) {
                newClass[ k ] = v;
            });
        },
        'extend':function (newClass, superClass) {
            var superClass = superClass || XNative , prototype = newClass.prototype , superPrototype = superClass.prototype;


            //process statics
            objectEach(superClass, function (k, v) {
                if( k !== 'prototype') //fix ff 3.5.9-
                    newClass[ k ] = v;
            });

            //process prototype
            objectEach(superPrototype, function (k, v) {
                prototype[ k ] = v;
            });

            //process mixins
            var mixins = newClass.mixins = [];

            if (superClass.mixins)
                mixins.push.apply( mixins , superClass.mixins );


            newClass.superclass = prototype.superclass = superClass;
        },
        'mixins':function (newClass, value) {
            if( value )
                arrayEach(value, function (v) {
                    if( typeof v === 'function')
                        newClass.mixin( v );
                    else if( v.mixin )
                        newClass.mixin( v.mixin , v.name )
                });
        }
    };

    var PROCESSOR_KEYS = ['statics', 'extend', 'mixins'];

    /**
     * @class XClass
     * @classdesc Class Factory
     * @param  {Object} params
     * @returns {XNative} The new Class
     * @example new XClass({
     *     statics : {
     *         static_method : function(){}
     *     },
     *     method1 : function(){},
     *     method2 : function(){},
     *     extend : ExtendedClass,
     *     mixins : [ MixedClass1 , MixedClass2 ],
     *     singleton : false
     * });
     */


    function XClass( params ){

        var params = params || {};

        var XNative = function(){
            return reset( this , XNative , params , arguments );
        };

        var methods = { $constructor : XNative };

        arrayEach(PROCESSOR_KEYS, function (key) {
            PROCESSOR[ key ](XNative, params[ key ], key);
        });

        objectEach(params, function (k, v) {
            if (!PROCESSOR[ k ])
                methods[ k ] = v;
        });

        extend.call(XNative.prototype, methods);

        return XNative;
    }

    function reset( instance , XNative , params , args ){

        var me = instance;

        if ( params.singleton )
            if (XNative.singleton)
                return XNative.singleton;
            else
                XNative.singleton = me;

        var mixins = XNative.mixins;

        arrayEach( mixins , function (mixin) {

            var name = mixin.name ,
                mixinClass = mixin.mixin ,
                fn = function(){ return mixinClass.apply( this , args );},
                obj;

            fn.prototype = mixinClass.prototype;

            obj = new fn();

            if( name )
                ns( 'mixins' , me )[ name ] = obj;

            me.implement( obj , true );

        });

        return me.initialize && me.initialize.apply(me, args ) || me;
    }


    /**
     * @namespace XClass.utils
     * */
    XClass.utils = {
        /**
         * @name XClass.utils.objectEach
         * @function
         * @desc Iterates through an object and invokes the given callback function for each iteration
         * @param {Object} object  The object ot iterate
         * @param {Function} The callback function
         */
        objectEach:objectEach,
        /**
         * @name XClass.utils.arrayEach
         * @function
         * @desc Iterates an array and invokes the given callback function for each iteration , It will call Array.prototype.forEach if supported
         * @param {Array} object  The array ot iterate
         * @param {Function} The callback function
         */
        arrayEach:arrayEach,
        /**
         * @name XClass.utils.ns
         * @function
         * @desc Creates namespaces to be used for scoping variables
         * @param {String} name  dot-namespaced format namespaces, for example: 'Myapp.package'
         * @param {Object} root  the root object, global if null
         * @returns {Object} The namespace object, if name is null , it returns the root
         */
        ns:ns
    };

    /**
     * @name XClass.define
     * @desc define a class
     * @param {String} className The class name to create in string dot-namespaced format, for example: 'Myapp.MyClass'
     * @param {Object} params The parameters for the new Class
     * @returns {XNative} The XNative Class
     */

    XClass.define = function (className, params) {
        if (className) {
            var lastIndex = className.lastIndexOf('.') , newClass;
            return ns(lastIndex === -1 ? null : className.substr(0, lastIndex))[ className.substr(lastIndex + 1) ] = new XClass(params);
        } else
            throw new Error('empty class name!');
    };

    global.XClass = XClass;

    // amd support
    if (typeof define === 'function' && define.amd)
        define('xclass', [], function () {
            return XClass;
        });

})(window);
/*
 * @Descripttion: 
 * @Author: whyjs
 * @Date: 2022-09-04 15:36:21
 * @LastEditors: whyjs
 * @LastEditTime: 2023-02-22 14:03:55
 */
(function( w ){
    
    // Function.prototype.bind = function (context) {
    //     var arg = Array.prototype.slice.call(arguments, 1);
    //     var self = this;
    //     return function () {
    //       var insideArgs = Array.prototype.slice.call(arguments);
    //       var fullArgs = arg.concat(insideArgs);
    //       return self.apply(context, fullArgs);
    //     };
    // };

    var Observable = new XClass({
        // singleton : true,
        //一旦被mixin，对象初始化时，initialize方法会被调用
        initialize: function () {
            this.events = {};
        },
        //绑定事件
        on: function (name, func) {
            if (!this.events[name]) this.events[name] = [func];
            else this.events[name].push(func);
        },
        //解绑所有
        unAll: function () {
            this.events = {};
        },
        //触发事件
        fireEvent: function (name, opts) {
            if (!this.events[name]) return;
            for (var i = 0, func; (func = this.events[name][i]); i++)
            func.apply(this, opts || []);
        },
    });

    var XUtils = new XClass({
        singleton : true,
        statics : {
            typeOf : function( object ){
                return Object.prototype.toString.call( object).slice( 8 , -1 ).toLowerCase();
            },
            clone : function( object ){
                if( object == null )
                    return object;

                var type = XUtils.typeOf( object );

                if( object.nodeType && object.cloneNode )
                    return object.cloneNode( true );

                switch( type ){
                    case 'date':
                        return new Date( object.getTime() );
                    case 'array':
                        var c = [];
                        XUtils.array.forEach( object , function( o , i ){
                            c[ i ] = XUtils.clone( o );
                        });
                        return c;
                    case 'object':
                        var c = {};
                        XUtils.object.each( object , function( k , v ){
                            c[ k ] = XUtils.clone( v );
                        } );
                        return c;
                    default :
                        return object;
                }
            },
            object : {
                each : XClass.utils.objectEach
            },
            array : {
                forEach : XClass.utils.arrayEach
            },
            isNumber : function (val){

                var regPos = /^[0-9]+.?[0-9]*/; //判断是否是数字。
              
                if(regPos.test(val) ){
                    return true;
                }else{
                    return false;
                }
            },
            //加减乘除
            math : {
                add : function(a, b) {
                    if(!a){
                        a=0
                    }
                    if(!b){
                        b=0
                    }
                    var c, d, e;
                    try {
                        c = a.toString().split(".")[1].length;
                    } catch (f) {
                        c = 0;
                    }
                    try {
                        d = b.toString().split(".")[1].length;
                    } catch (f) {
                        d = 0;
                    }
                    return e = Math.pow(10, Math.max(c, d)), (XUtils.math.mul(a, e) + XUtils.math.mul(b, e)) / e;
                },
                
                sub : function(a, b) {
                    if(!a){
                        a=0
                    }
                    if(!b){
                        b=0
                    }
                    var c, d, e;
                    try {
                        c = a.toString().split(".")[1].length;
                    } catch (f) {
                        c = 0;
                    }
                    try {
                        d = b.toString().split(".")[1].length;
                    } catch (f) {
                        d = 0;
                    }
                    return e = Math.pow(10, Math.max(c, d)), (XUtils.math.mul(a, e) - XUtils.math.mul(b, e)) / e;
                },
                 mul : function(a, b) {
                    if(!a){
                        a=0
                    }
                    if(!b){
                        b=0
                    }
                    var c = 0,
                        d = a.toString(),
                        e = b.toString();
                    try {
                        c += d.split(".")[1].length;
                    } catch (f) {}
                    try {
                        c += e.split(".")[1].length;
                    } catch (f) {}
                    return Number(d.replace(".", "")) * Number(e.replace(".", "")) / Math.pow(10, c);
                },
                
                 div : function(a, b) {
                    if(!a){
                        a=0
                    }
                    if(!b){
                        b=0
                    }
                    var c, d, e = 0,
                        f = 0;
                    try {
                        e = a.toString().split(".")[1].length;
                    } catch (g) {}
                    try {
                        f = b.toString().split(".")[1].length;
                    } catch (g) {}
                    return c = Number(a.toString().replace(".", "")), d = Number(b.toString().replace(".", "")), XUtils.math.mul(c / d, Math.pow(10, f - e));
                },
                sum : function (arr) {
                    var t = 0
                    for(var i=0;i<arr.length;i++){ t = XUtils.math.add(t,arr[i]) }
                    return t || 0
                },
                changeNumMoneyToChinese:function(money){//人民币转大写
                    var cnNums = new Array("零", "壹", "贰", "叁", "肆", "伍", "陆", "柒", "捌", "玖"); //汉字的数字
                    var cnIntRadice = new Array("", "拾", "佰", "仟"); //基本单位
                    var cnIntUnits = new Array("", "万", "亿", "兆"); //对应整数部分扩展单位
                    var cnDecUnits = new Array("角", "分", "毫", "厘"); //对应小数部分单位
                    var cnInteger = "整"; //整数金额时后面跟的字符
                    var cnIntLast = "元"; //整型完以后的单位
                    var maxNum = 999999999999999.9999; //最大处理的数字
                    var IntegerNum; //金额整数部分
                    var DecimalNum; //金额小数部分
                    var ChineseStr = ""; //输出的中文金额字符串
                    var parts; //分离金额后用的数组，预定义    
                    var Symbol="";//正负值标记
                    if (money == "") {
                        return "";
                    }
              
                    money = parseFloat(money);
                    if (money >= maxNum) {
                        alert('超出最大处理数字');
                        return "";
                    }
                    if(money<0.01){
                      return ""
                    }
                    if (money == 0) {
                        ChineseStr = cnNums[0] + cnIntLast + cnInteger;
                        return ChineseStr;
                    }
                    if(money<0)
                    {
                        money=-money;
                        Symbol="负 ";        
                    }
                    money = money.toString(); //转换为字符串
                    if (money.indexOf(".") == -1) {
                        IntegerNum = money;
                        DecimalNum = '';
                    } else {
                        parts = money.split(".");
                        IntegerNum = parts[0];
                        DecimalNum = parts[1].substr(0, 4);
                    }
                    if (parseInt(IntegerNum, 10) > 0) { //获取整型部分转换
                        var zeroCount = 0;
                        var IntLen = IntegerNum.length;
                        for (var i = 0; i < IntLen; i++) {
                            var n = IntegerNum.substr(i, 1);
                            var p = IntLen - i - 1;
                            var q = p / 4;
                            var m = p % 4;
                            if (n == "0") {
                                zeroCount++;
                            }
                            else {
                                if (zeroCount > 0) {
                                    ChineseStr += cnNums[0];
                                }
                                zeroCount = 0; //归零
                                ChineseStr += cnNums[parseInt(n)] + cnIntRadice[m];
                            }
                            if (m == 0 && zeroCount < 4) {
                                ChineseStr += cnIntUnits[q];
                            }
                        }
                        ChineseStr += cnIntLast;
                        //整型部分处理完毕
                    }
                    if (DecimalNum != '') { //小数部分
                        var decLen = DecimalNum.length;
                        for (var i = 0; i < decLen; i++) {
                            var n = DecimalNum.substr(i, 1);
                            if (n != '0') {
                                ChineseStr += cnNums[Number(n)] + cnDecUnits[i];
                            }
                        }
                    }
                    if (ChineseStr == '') {
                        ChineseStr += cnNums[0] + cnIntLast + cnInteger;
                    } else if (DecimalNum == '') {
                        ChineseStr += cnInteger;
                    }
                    ChineseStr = Symbol +ChineseStr;
                    return ChineseStr;
                }
            },
            getTpl : function (id) {
                return function () {
                    return document.getElementById(id).innerHTML
                } 
            },
            each : function( object , func ){
                if( XUtils.typeOf(object) === 'array' )
                    XUtils.array.forEach( object , func );
                else
                    XUtils.object.each( object , func );
            },
            ns : XClass.utils.ns,

            namespace : XClass.utils.ns
        }
    });

    w.XUtils = XUtils;

    w.Observable = Observable;

})(window);